title: Javascript Function Not Firing from C# Function ASP.Net
body: <p>I am using a asp:Repeater control while trying to develop a screen as shown below:
  <a href="https://i.stack.imgur.com/KapIu.jpg" rel="nofollow noreferrer">Submit form</a></p>
  
  <p>When <strong>ToolId</strong> is entered on the TextChanged Event I am getting value for MaxToolLife stored as double. When an user enter values greater than the stored value for the field <strong>ToolLife</strong> I need to show Yes/No popup stating "The value entered is greater than existing value. Do you want to proceed?" on button submit or textchanged event.
  Currently I am using the below code but I am not getting Javascript alert.</p>
  
  <pre><code>protected void btnSubmit_Click(object sender, EventArgs e)
  {
      if (Convert.ToDouble(txtToolLifeAchieved.Text) &gt; maxToolLife)
      {
          Page.ClientScript.RegisterStartupScript(Page.GetType(), "Confirm", "javascript:Confirm();", true);
  
          if (hdnconfirm.Value=="Yes")
          {
              row["Pcs Produced"] = Convert.ToDouble(txtToolLifeAchieved.Text);
          }
          else
          {
              txtToolLifeAchieved.Text = "1";
              txtToolLifeAchieved.Focus();
              return;
          }
      }
      else
      {
          row["Pcs Produced"] = Convert.ToDouble(txtToolLifeAchieved.Text);
      }
  }
  </code></pre>
  
  <p>In place of Page.ClientScript I have also used "Page.ClientScript.RegisterClientScriptBlock" &amp; /ScriptManager.RegisterStartupScript. Nothing is working as of now. I am unable to call the javascript function from code behind. Any immediate response would help a lot.</p>
  
  <p>The confirm() is as shown below:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function Confirm()
  { 
    var confirm_value = document.createElement("INPUT"); 
    confirm_value.type = "hidden"; 
    confirm_value.name = "confirm_value"; 
    if (confirm("The data already exists. Do you want to Overwrite data?")) 
    { 
      confirm_value.value = "Yes"; 
      document.getElementById('&lt;%= hdnconfirm.ClientID %&gt;').value = "Yes"; 
    } 
    else 
    { 
      confirm_value.value = "No"; 
      document.getElementById('&lt;%= hdnconfirm.ClientID %&gt;').value = "No";   
    }
    
    document.forms[0].appendChild(confirm_value); 
  }</code></pre>
  </div>
  </div>
  </p>