D
David Hirschfeld
A while back I learned how to create a default button
click event when the enter key is pressed by inserting
the following code:
Page.RegisterHiddenField("__EVENTTARGET", "butSearch")
However, I originally implemented incorrectly as follows:
Page.RegisterHiddenField("__EventTarget", "butSearch")
The only difference is the case of __EventTarget. Both
methods work. However, if you are using User Controls as
I am, and if you have one user control for the header of
your web page, and another User Control for the content
with an embedded DataGrid control, the 'Mixed Case'
version disables both paging and sorting. I can only
guess why this happens. It took me a couple days to
figure out what happened to my paging and sorting.
The difference in HTML output between these two versions
is as follows.
'All Caps' - Correct
<input type="hidden" name="__EVENTTARGET"
value="butSearch" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
'Mixed Case' - Incorrect
<input type="hidden" name="__EventTarget"
value="butSearch" />
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
I can only guess that both the Sort and Paging commands
share the hidden input with many other default postback
actions. The additional 'Mixed Case' hidden input,
somehow overrides the 'All Caps' input. If someone has a
more insightful explanation, I would like to hear it.
Regardless, developers should be made aware of this
idiosyncrasy.
click event when the enter key is pressed by inserting
the following code:
Page.RegisterHiddenField("__EVENTTARGET", "butSearch")
However, I originally implemented incorrectly as follows:
Page.RegisterHiddenField("__EventTarget", "butSearch")
The only difference is the case of __EventTarget. Both
methods work. However, if you are using User Controls as
I am, and if you have one user control for the header of
your web page, and another User Control for the content
with an embedded DataGrid control, the 'Mixed Case'
version disables both paging and sorting. I can only
guess why this happens. It took me a couple days to
figure out what happened to my paging and sorting.
The difference in HTML output between these two versions
is as follows.
'All Caps' - Correct
<input type="hidden" name="__EVENTTARGET"
value="butSearch" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
'Mixed Case' - Incorrect
<input type="hidden" name="__EventTarget"
value="butSearch" />
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
I can only guess that both the Sort and Paging commands
share the hidden input with many other default postback
actions. The additional 'Mixed Case' hidden input,
somehow overrides the 'All Caps' input. If someone has a
more insightful explanation, I would like to hear it.
Regardless, developers should be made aware of this
idiosyncrasy.