Help on Strange Return Key Behaviour

A

Andrea

I have a text box and a Button.

If I click on the button, the page is posted and the Click event is fired.
If I hit return on the text box (the browser should post the page like click
on button) the page is posted, but the click event is not fired.

Someone can help me on this problem.
Thanks.

Andrew
 
J

Jeffrey Palermo [MCP]

Andrea,
Steve is correct. If you want to perform some functionality if the
textbox is changed and the user hits enter, then the following code snippet
may be useful: (if textbox isn't changed, the event will not fire).
private void btn_Click(object sender, System.EventArgs e)

{

Trace.Warn("Button Clicked");

}



private void txt_TextChanged(object sender, System.EventArgs e)

{

btn_Click(sender, e);

}


Or if there is something that needs to be done on every postback, you may
just want to put that logic in Page_Load and check that IsPostBack is true.

--
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top