469,568 Members | 1,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

event mechanism behaves in unexpected way.

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("n etscape") > -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" />
.....
Nov 18 '05 #1
0 801

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Zachary | last post: by
10 posts views Thread by tony kulik | last post: by
1 post views Thread by Daniel Bass | last post: by
2 posts views Thread by tneilson | last post: by
22 posts views Thread by Oriane | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.