开发者

button_click upon pressing Return in TextBox - ASP.NET

I've got an ASP WebForm with 2 Textboxes and 3 Buttons and I want a specific button_click event to be fired whenever I press return whilst in a TextBox - how would I achieve this?

I tried using the TabIndex-Property, unfortunately that actually only seems to 开发者_JAVA百科work for tabbing, not for pressing return in a TextBox.

Thanks!


Hey everyone, thanks for your answers - I just found the solution, for an aspx-page within a MasterPage I need to set

Form.DefaultButton = myButton.UniqueID;

instead of

Form.DefaultButton = myButton.ID;

which throws an error.

Thanks everyone!


Set the form's AcceptButton to the button you want pressed:

form1.AcceptButton = btnOK;


You can set which button is to be used as the default directly in mark-up of controls, by settings the defaultbutton property value to the ID of the desired button control, try this:

<form id="form1" runat="server" defaultbutton="DefaultButtonId">
    <!-- content -->
</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜