This is a migrated thread and some comments may be shown as answers.

Turn off Ajax and enable postback for current request in code behind

2 Answers 196 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Dave Miller
Top achievements
Rank 2
Dave Miller asked on 04 Mar 2013, 10:33 PM
I have a button on a form that vaidates the imput and then when validated submits it.

Is it possible to disable ajax for an ajaxified button for the current request and cause a full postback in a function in the code behind.
 
for instance:

protected void btnSubmitForm2_Click(object sender, System.EventArgs e)
       {
           if (ValidUserInfo())
           {
               // Code to turn off RadAjaxManager ajax request for this call
               lblErrorMsg.Text = "Valid"; //Updated via full postback
           }
           else
           {
               lblErrorMsg.Text = "Invalid"; //Updated via RadAjaxManager
           }
 
       }


Thanks in advance!

Regards,
Dave



2 Answers, 1 is accepted

Sort by
0
Accepted
MasterChiefMasterChef
Top achievements
Rank 2
answered on 05 Mar 2013, 03:18 PM
Hi Dave Miller,

There is a simple way to perform a postback in the javascript code. Simply calling myForm.submit() will work, as will location.reload() . If these won't work for you, you may want to look at this post concerning performing a postback inside of an ASP.NET AJAX application.

Hopefully this helps,
Master Chief
0
Dave Miller
Top achievements
Rank 2
answered on 05 Mar 2013, 05:26 PM

Master Chief,

I was looking for a function within RadAjaxManager that didnt require a postback to set it or completly disable ajax for the item.

Didn't even think of something so simple as calling myForm.submit().

One thing to add is for Firefox it needs to be document.myForm.submit().

Adding this to the function where I want the postback works perfectly!!!

ScriptManager.RegisterClientScriptBlock(
this.Page,
this.GetType(),
"WebUserControlSript",
"document.form1.submit()",
true);


Thanks!

Best regards,
Dave

Tags
Ajax
Asked by
Dave Miller
Top achievements
Rank 2
Answers by
MasterChiefMasterChef
Top achievements
Rank 2
Dave Miller
Top achievements
Rank 2
Share this question
or