Not sure if this is the best way to do this, but this is what I do. Say you want to auto submit a form on an aspx page. You can call document.formname.submit(); from the body onLoad event and it will submit, but ASP.net will automatically post it back to itself.
First, what I had to do was put on my ASP Classic hat. Look at your <form> and remove the runat=”server”
Then, you can say document.formname.submit(); and it will submit your form.
How do you pass data though?
Well, you have to created input fields, probably hidden like
<input type=”hidden” name=”blah” id=”blah” value=”<%= Request.QueryString[“myvalue”] %>” />
Then you can pass data from another page or whatever and auto submit your form.
It would be nice if you could say in your Page_Load() something like
btnSubmit.Click(); and it would automatically click it and submit your form, but that doesn’t seem to be available at all.
Like I said, there is probably a better way to do this, and it shouldn’t be this complicated, but a few minutes googling for answers left me up in the air. Funny how something that is so easy in ASP Classic turns out to be harder in ASP.NET. ASP.NET wants you to really post back to the same page by default. It hijacks the “action” attribute on the form no matter what with runat=”server on there.
Maybe there are some tips for you in my “How to serialize forms” chapter; http://ra-ajax.org/how-to-create-an-ajax-library-part-6-serializing-your-forms.blog
This solution will tough to me because my application is already completed. I can not make this change at this moment.
do you have any simple solution to avoid the IE refresh alert which comes after the page submit while saving the data to database. ?
I want to bypass only this given alert. nothing more that.
Windows Internet Explorer
To display the webpage again, Internet Explorer needs to
resend the information you’ve previously submitted.
If you were making a purchase, you should click Cancel to
avoid a duplicate transaction. Otherwise, click Retry to display
the webpage again.
I am not getting that how it is getting resubmitted.
There can be small trick or something for this which I am trying to find to bypass this message.
Same query as above. Anyone knowing the answer please reply.!
plese help me with java script so i can play games. thanks so much.. brenda johnson