title: How do I stop code executing when displaying a Telerik radAlert from server-side
body: <p>I am currently implementing a check in my master page page_load event which confirms whether or not the session is being used by another tab as the application I'm working on wasn't initially designed to support multiple tabs.  </p>
  
  <p>So when a forms save button is clicked, the master page page_load code executes and my RadAlert is displayed on condition.  The RadAlert dialog calls a javascript page reload function on the window close or ok click so I want the remaining server side code to stop executing as when the forms click event is executed the record is saved and this can't happen as there could be corrupted session data.</p>
  
  <p>Is there any way to stop the code from executing other than going into every pages click events and manually performing this same condition in there and returning?</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {           
          if (!Page.IsPostBack)
          {
              string strGuid = Guid.NewGuid().ToString().Replace("-", "");
              HiddenGuid.Value = strGuid;
              //Session["SessionId"] = strGuid;
              SessionHandler.SessionId = strGuid;
          }
          else if (Page.IsPostBack)
          {                
              if (HiddenGuid.Value != SessionHandler.SessionId) 
              {
                  //Telerik.Web.UI.RadWindowManager radWindowManager = (Telerik.Web.UI.RadWindowManager)this.Page.Master.FindControl("wmrDialogs");
                  string msg = "Your form did not submit successfully as using multiple tabs can cause errors when submitting forms." + 
                      " This page will now reload. Please re-enter your changes and re-submit the form.";
                  string title = "Potential Multiple Tab Error";
                  wmrDialogs.RadAlert(msg, 500, 150, title, "ReloadPage");
              }                
          }
  </code></pre>
  
  <p>Is there any way to stop the code from executing other than going into every pages click events and manually performing this same condition in there and returning?  I really want to avoid doing the following if possible:</p>
  
  <pre><code>protected void Save_Click(object sender, EventArgs e)
  {
      //  if not current session do not execute save
      if(!AppUtils.IsCurrentSession(((HiddenField)this.Page.Master.FindControl("HiddenGuid")).Value))
      {
          // do nothing
          return;
      }
  }
  </code></pre>
  
  <p>I have tried response.end() which stops the page before the dialog (alert) is displayed which also stops the page from being reloaded via javascript.</p>
  
  <p>I've also tried response.redirect but this redirects before the dialog is displayed so I have no way of notifying the user as to what is going on.</p>
  
  <p>Any help would be much appreciated.</p>