W
w. jORDAN
Hello all,
It's known to how to make user press enter
in an asp:textbox and the form is submited by
adding an attribute to the textbox with an
onkeydown jscript eventhandler.
For example,
-----------------------------------------
<asp:textbox id="t1" runat="server"/>
<asp:button id="b1" runat="server"/>
page_load event:
t1.Attributes.Add("onkeypress", "submitForm();");
Client-side Script:
function submitForm()
{
if (event.keyCode == 13)
{
event.cancelBubble = true;
event.returnValue = false;
document.all.b1.click();
}
}
-----------------------------------------
The above should work well when used inside an
ASPX page.
However, my situation now is the thing happens
inside an ASCX, a dynamically loaded user
control.
As u all know, the actual ID of the asp:button
varies when the control is rendered.
It could be
parentCtrl__ctl0_b1
or something else.
So the trick in the client side script has to
be modified. But how to? And any other more
flexible ways? Somebody plz give me some hints!
Jordan
It's known to how to make user press enter
in an asp:textbox and the form is submited by
adding an attribute to the textbox with an
onkeydown jscript eventhandler.
For example,
-----------------------------------------
<asp:textbox id="t1" runat="server"/>
<asp:button id="b1" runat="server"/>
page_load event:
t1.Attributes.Add("onkeypress", "submitForm();");
Client-side Script:
function submitForm()
{
if (event.keyCode == 13)
{
event.cancelBubble = true;
event.returnValue = false;
document.all.b1.click();
}
}
-----------------------------------------
The above should work well when used inside an
ASPX page.
However, my situation now is the thing happens
inside an ASCX, a dynamically loaded user
control.
As u all know, the actual ID of the asp:button
varies when the control is rendered.
It could be
parentCtrl__ctl0_b1
or something else.
So the trick in the client side script has to
be modified. But how to? And any other more
flexible ways? Somebody plz give me some hints!
Jordan