0

Possible Duplicate:
Perform Button click event when user press Enter key in Textbox

I want to trace an enter button keypress event in asp.net and c#.I dont want to use javascript for it.

whenever there is Enter press in the textbox I want to call a function that takes as parameters the textbox value.

0

2 Answers 2

0

Well there are several ways to do it:

Using a Panel

<asp:Panel runat="server" DefaultButton="but">
    <asp:TextBox runat="server" ID="txt" />
    <asp:Button Text="text1" runat="server" ID="but" OnClick="click" />
</asp:Panel>

Specifying the default button in the Form tag

<form id="form1" runat="server" defaultbutton="but" defaultfocus="txt">
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your response.I already have a form tag in my page,and I think I cannot use another form tag.
The attributes are applied to the only form available in an ASP.Net page, the defaultbutton only specifies which button will be executed when you press enter, the rest of your controls will work the same way
0

Cannot capture/trace the keypress event in ASP.NET without JavaScript.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.