title: create c# code of onclick function in aspx.cs
body: <p>What I'm trying to do is to call a function in aspx.cs from aspx file.</p>
  
  <p><strong>JavaScript code:</strong> (for which I'm trying to make c# function in aspx.cs file)</p>
  
  <pre><code>function myconfirm() {
  
      var txt;
      var x = confirm("confirmation!!");
      if (x == true) {
  
          txt = " Your Request is Submitted!";
      }
      else {
          txt = "Verify and Confirm!";
      }
      document.getElementById("verify").innerHTML = txt;
  
      return false;
  }
  </code></pre>
  
  <p><strong>c# code in aspx.cs:</strong> (This is what I'm trying out and getting a error)</p>
  
  <pre><code>namespace TESTING
  {
  public partial class _Default : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
      }
      public void myconfirm(object sender, EventArgs e)
      {
          string x = "confirmation!!";
          string txt;
          if (x == "true")
          {
              txt = "your request is submitted";
          }
          else
          {
              txt = "verify and confirm ";
          }
      }
  
          public void myconfirm1(object sender, EventArgs e)
          {
              string y="confirmation!!";
              string text;
              if(y=="true")
              {
                  text="we are tracking your PRN";
              }
              else{
                  text="verify and confirm!!";
              }
      }
  }
  }
  </code></pre>
  
  <p><strong>calling it from aspx file:</strong>   </p>
  
  <pre><code>&lt;asp: Button ID="Button3" runat="server" Text="SUBMIT" OnClick="myconfirm"&gt;&lt;/asp: Button&gt;
  </code></pre>
  
  <p><strong>error I'm getting</strong></p>
  
  <blockquote>
    <p>'myconfirm1' is undefined"                                                                                       </p>
  </blockquote>
  
  <p><strong>Summarising it</strong>:</p>
  
  <ol>
  <li>DEFINE A ONCLICK METHOD IN ASPX.CS FILE from c#.</li>
  <li>calling it from aspx file.</li>
  </ol>
  
  <p><strong>Problems occurring</strong>:</p>
  
  <ol>
  <li>lack of basic concept of how to exactly write the c# code in aspx.cs file.</li>
  </ol>
  
  <p><em>And also If anyone can give a brief concept of how to write c# code in aspx.cs to be called from aspx file.</em></p>