ASP.NET use jQuery $.post for ajax

Hello World,I came through an interesting scenario which required us to change an ASP.NET form submit to ensure that the browser does not show this message:

Now this page only shows a report and this prompt is completely out of place and is actually an irritant to the end user. I’ve tried changing the aspx form method to GET instead of POST as this prompt only seems to come for a page with form data, but that breaks the functionality of the page.  I was at my wits end now with how to disable this prompt from being shown?

More Details

This aspx page I am working with has tabs and radio buttons as server side HTML controls. Their statuses are maintained through hidden fields embedded in the page. Once the values of the hidden fields are set and the aspnet form submitted, that’s when the browser starts detecting any refresh as a resubmission and shows the dialogue. I have gotten past the issue, details as follows:

We have now changed the form.submit() to a jQuery $.post() that looks like below:

$.post(myForm.action, request, function(d) {
                        // Callback funtion that uses the returned response data d
                        // to extract the html and render the page again after completion
                        // of the Ajax request
                    });

request: Is the json object containing the key:value pairs that maintain state of the controls

Note: In the Page_Load() method of the aspx page, one needs to set the values of the hidden fields by reading them from the HttpContext’s Request object

Entire discussion and solution on this stackoverflow link
Happy Coding

Advertisements
Posted in ASP.NET, JavaScript, jQuery

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

  • Comic for May 23, 2017
    Dilbert readers - Please visit Dilbert.com to read this feature. Due to changes with our feeds, we are now making this RSS feed a link to Dilbert.com.
%d bloggers like this: