event mechanism behaves in unexpected way.

F

Francois Malgreve

Hi all,

I have a more or less complex form with a few buttons and a few input
fields.
One of my my input field ( a TextBox) I have an event handler for the
TextChanged event.
What I want is that when I will hit enter in my input field, I expect to
form to be posted back to the server and the event handler for the
TextChanged event to be called.
If i tabulate from my text field, everythign is working fine. Nevertheless
when I hit the <enter> key instead of tabulating, then not only event
handler for that field is called but also the event handler of the first
button of my form. Why does this event fires? Is it because when I hit
<enter> the browser, translate it as if I clicked on that button? Or is it
due to some event mechanism in ASP.NET? Could anyone who understand what
really happen under the bush could explain it to me? And maybe give me a
hint on how to accomplish the desired behaviour.

Thanks in advance.

Here is some excerpts of my code:

ASPX page:
.....
<asp:textbox id="TextBoxInputAccountId" style="Z-INDEX: 150; LEFT: 312px;
POSITION: absolute; TOP: 8px" runat="server" Width="80px"
AutoPostBack="True">
.....



Code behind class:
In the InitializeComponent() called from the OnInit() method I have the
registration of my event handler for my event:
.....
this.TextBoxInputAccountId.TextChanged += new
System.EventHandler(this.LoadAccountDetail);
.....


Generated HTML code for IE browser:

<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["FormMemberDetails"];
}
else {
theform = document.FormMemberDetails;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>

.....
<input name="TextBoxInputAccountId" type="text"
onchange="__doPostBack('TextBoxInputAccountId','')" language="javascript"
id="TextBoxInputAccountId" />
.....
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top