TextChanged of TextBox and Click on Button

G

Guest

Hi all
I am having a 10 textboxs on a page and 2 button .One TextBox is having a TextChanged event attached to it .My problem is when the User changes some text in same text box for which the Textchanged is attached and without tabbing out clicks the Submit button,Text change events fires twice and submit button doesnt submit the page
And the Interesting thing is that sometimes on some browser it works fine and submit the page
Please help me....
 
M

matt

Sounds like you might have the AutoPostBack property of your textbox set to
true, this will automatically post back the form to the server after the
contents of the textbox is modified. Try setting this to false, and your
form will only be submitted when the submit button is clicked, and this will
cause your submit_click (or whatever you've called it) event will fire, as
will the textbox changed event.

Hope that solves your problem

Matt
http://www.3internet.co.uk
Inigo Content Management System - c#, asp.net, xml cms

Neeraj said:
Hi all,
I am having a 10 textboxs on a page and 2 button .One TextBox is having a
TextChanged event attached to it .My problem is when the User changes some
text in same text box for which the Textchanged is attached and without
tabbing out clicks the Submit button,Text change events fires twice and
submit button doesnt submit the page.
 
G

Guest

Thanks for answering my prob but i want the TextChange event so i ve to set the AutoPostBack property true
My problem is :-when the user clicks the Submit button the page should be submitted.I dont want the page to fire the TextChange event when the user clicks the Submit button.
 
M

matt

You could just check for the value of the submit button in the form
collection from within your textchange event to see if the submit button was
clicked, if the submit button wasn't clicked then do the processing.... If
the submit button was clicked then there will be a corresponding value in
the form collection when the button has been clicked, this is how the server
knows that the button has been clicked. There's probably a better way to
do it, but that's one way that I know should work...


Neeraj said:
Thanks for answering my prob but i want the TextChange event so i ve to
set the AutoPostBack property true.
My problem is :-when the user clicks the Submit button the page should be
submitted.I dont want the page to fire the TextChange event when the user
clicks the Submit button.
 
G

Guest

Can you please send me the code because i dont get any value in the Form collection

Thanks
Neeraj
 
M

matt

Best thing to do is turn on tracing and look at what is submitted in the
form collection. You can confirm the name of the form collection element
you need to reference by looking at the html generated, and seeing the name
attribute this is the value you should refer to in your code using the
syntax Request.Form["submitButtonName"] if this is not null then the submit
button was clicked....

Matt
 

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

Top