Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger submit button on multi line textbox condition (ASP.NET, C#)

Status
Not open for further replies.

proximity

Technical User
Sep 19, 2002
132
GB
Hi . . . here's an interesting puzzle!

I have a multi line text box:
<asp:TextBox ID="txtData" runat="server" TextMode="MultiLine" />

Now, suppose a user enters the following:
123456
123457
123458
123459
222111
END

As soon as the user types in END, how do I get it to trigger a Submit button (or code module). The submit button sends the data to a database. And this is fine. But I don't want the user to click the submit button, it should just happen as soon as he types the word END!!

Can anyone offer up any suggestions?

 
You would have to write javascript to detect it. Then, do an ajax call to submit data to the database. If you decide to do it, I would use the JQuery framework. It makes doing javascript stuff easier, especially the ajax calls
 
Hi, thanks for the response. I had a nagging feeling that JQuery would be the way to go . . . . . it certainly seems impossible in .net. Looks like I have some reading up to do as JQuery is not my bag!
 
You can do it with server side code, but it doesn't really make sense.
There is a textchanged event on the textbox, however, that only fires on a postback. So potentially you can use javascript to detect "END" and then trigger a postback to have that code run.
But after using JQuery for awhile, I would just use that instead. It's not bad. Makes javscript programming much simpler. Just a learning curve, like anything else new you learn.
 
You should use javascript or jquery to detect word END in textbox and when detected call event click of submit button just
document.getElementById("btnSubmit").click();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top