Running code/script as a result of a form submission in ASP.NET

Posted by firmbeliever on Stack Overflow See other posts from Stack Overflow or by firmbeliever
Published on 2010-04-20T22:39:21Z Indexed on 2010/04/20 22:43 UTC
Read the original article Hit count: 241

Filed under:
|
|

An outside vendor did some html work for us, and I'm filling in the actual functionality. I have an issue that I need help with.

He created a simple html page that is opened as a modal pop-up. It contains a form with a few input fields and a submit button. On submitting, an email should be sent using info from the input fields.

I turned his simple html page into a simple aspx page, added runat=server to the form, and added the c# code inside script tags to create and send the email.

It technically works but has a big issue. After the information is submitted and the email is sent, the page (which is supposed to just be a modal pop-up type thing) gets reloaded, but it is now no longer a pop-up. It's reloaded as a standalone page.

So I'm trying to find out if there is a way to get the form to just execute those few lines of c# code on submission without reloading the form. I'm somewhat aware of cgi scripts, but from what I've read, that can be buggy with IIS and all. Plus I'd like to think I could get these few lines of code to run without creating a separate executable.

Any help is greatly appreciated.

© Stack Overflow or respective owner

Related posts about form

Related posts about ASP.NET