Help on Strange Return Key Behaviour

  • Thread starter Thread starter Andrea
  • Start date Start date
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
 
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
 
Back
Top