title: Stop execution of a page
body: <p>I have a task board, some person is working on some task, if task is assigned to another person by his manager the first person who is working on the task board, his execution should be stopped, and a message should be displayed that "This task is assigned to some one else."</p>
  
  <p>I tried using following in page load.</p>
  
  <pre class="lang-cs prettyprint-override"><code>//Code Behind
  if (!Owner)
  {
      SomecontrolsToHide();
      MessageDisplay();    // JavaScript function call using RegisterStartupScript()
      Response.End();    
  }
  
  protected void MessageDisplay()
  {
      string dbMessage = "Task is assigned to someone else.";
      ClientScriptManager cs = Page.ClientScript;
      cs.RegisterStartupScript(typeof(Page), "ShowMessageWrapup_" + UniqueID, "showMessageDisplay('','" + dbMessage + "');", true);   
  }
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>// JavaScript function that displays message.
  function showMessageDisplay(args, displayMessage) {
      if (displayMessage != "") {                        
          document.getElementById("spanMessage").innerHTML = displayMessage;
          document.getElementById("spanMessage").style.display = 'inline';
      }
  }
  </code></pre>
  
  <p>It stops the execution but message is not displayed and Controls are not hidden too.</p>
  
  <p>What should I do?</p>