title: ScriptManager.RegisterStartupScript() method not working - ASP.NET, C#
body: <p>I have used <code>ScriptManager.RegisterStartupScript()</code> method in order to show an alert when particular thing happens in back end.It works fine in page load method but not in particular method which is called when a specific button is clicked . I Couldn't find a solution because in another page it works fine in both page load and the method.</p>
  
  <p><b>Script Manager RegisterStartupScript Method</b><br/></p>
  
  <pre><code>ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", "alert('msg');", true);
  </code></pre>
  
  <p><b>HTML</b><br/></p>
  
  <pre><code>&lt;asp:HiddenField runat="server" ClientIDMode="Static" ID="PostBackController"/&gt;
  &lt;button class="some-class" id="btnSave" runat="server" onclick="btnSave_clientClick();"&gt;SAVE&lt;/button&gt;
  </code></pre>
  
  <p><b>Javascript</b><br></p>
  
  <pre><code>function btnSave_clientClick() {
  
       // code
  
       if (some_condition) {
  
          $('#PostBackController').val("btn_save");
          __doPostBack();
  
       }
  }
  </code></pre>
  
  <p><b>Page Load Method</b><br/></p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (PostBackController.Value == "btn_save")
      {
          uploadDocSave_ServerClick();
      }
  }
  </code></pre>
  
  <p><b>Method Wish should be called when button Clicked</b></p>
  
  <pre><code>protected void uploadDocSave_ServerClick()
  {
      ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", "alert('msg');", true);
  }
  </code></pre>