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

3 posts, 1 answers
  1. Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 04 Mar 2013 Link to this post

    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. Answer
    MasterChiefMasterChef
    MasterChiefMasterChef avatar
    152 posts
    Member since:
    Jan 2013

    Posted 05 Mar 2013 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 05 Mar 2013 Link to this post

    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

Back to Top