title: Using jquery with ASP.net and C#
body: <p>In my C# i used this code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Data.SqlClient;
  using System.Configuration;
  
  public partial class _Default : System.Web.UI.Page
  {
  
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ASPConnectionString"].ConnectionString);
  
  
      protected void Page_Load(object sender, EventArgs e)
      {
          con.Open();
  
      }
      protected void SubmitButtonClick(object sender, EventArgs e)
      {
          SqlCommand cmd = new SqlCommand("INSERT INTO Students (Name,City,Age) Values(@Name,@City,@Age)", con);
          cmd.Parameters.AddWithValue("@Name", NameText.Text);
          cmd.Parameters.AddWithValue("@City", CityText.Text);
          cmd.Parameters.AddWithValue("@Age", Convert.ToInt32(AgeText.Text));
          cmd.ExecuteNonQuery();
          con.Close();
          SuccessMessage.Visible = true;
          SuccessMessage.Text = "Successfully Inserted data";
          CityText.Text = "";
          NameText.Text = "";
          AgeText.Text = "";
  
          ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "showalert();", true);
  
      }
  
  }
  </code></pre>
  
  <p>And my ASPX:</p>
  
  <pre><code>   &lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;style type="text/css"&gt;
          .auto-style1
          {
              text-align: center;
          }
  
          .auto-style2
          {
              width: 163px;
          }
  
          .auto-style3
          {
              text-align: center;
          }
  
          .auto-style4
          {
              font-size: large;
          }
  
          .auto-style5
          {
              text-align: right;
          }
  
          .auto-style6
          {
              width: 112px;
          }
  
          .auto-style7
          {
              text-align: center;
              width: 163px;
          }
      &lt;/style&gt;
  
  
  &lt;/head&gt;
  &lt;body&gt;
  
  
  
  &lt;div id="dialog" title="Basic dialog"&gt;
    &lt;p&gt;insert succussfly&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;button id="opener"&gt;Open Dialog&lt;/button&gt;
  
      &lt;form id="form1" runat="server"&gt;
  
  
          &lt;div&gt;
  
              &lt;div class="auto-style3"&gt;
                  &lt;span class="auto-style4"&gt;Inserting Data to DB&lt;br /&gt;
                  &lt;/span&gt;
              &lt;/div&gt;
              &lt;table align="center" style="width: 41%; height: 179px;"&gt;
                  &lt;tr&gt;
                      &lt;td class="auto-style5"&gt;Name:&lt;/td&gt;
                      &lt;td class="auto-style6"&gt;
                          &lt;asp:TextBox ID="NameText" runat="server"&gt;&lt;/asp:TextBox&gt;
                      &lt;/td&gt;
                      &lt;td class="auto-style2"&gt;
                          &lt;asp:RequiredFieldValidator ID="NameValidation" runat="server"
                              ControlToValidate="NameText" ErrorMessage="Name is reqiured"
                              Style="color: #FF0000; text-align: left"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td class="auto-style5"&gt;City:&lt;/td&gt;
                      &lt;td class="auto-style6"&gt;
                          &lt;asp:TextBox ID="CityText" runat="server"&gt;&lt;/asp:TextBox&gt;
                      &lt;/td&gt;
                      &lt;td class="auto-style2"&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td class="auto-style5"&gt;Age:&lt;/td&gt;
                      &lt;td class="auto-style6"&gt;
                          &lt;asp:TextBox ID="AgeText" runat="server"&gt;&lt;/asp:TextBox&gt;
                      &lt;/td&gt;
                      &lt;td class="auto-style2"&gt;
                          &lt;asp:RangeValidator ID="AgeValidation" runat="server"
                              ControlToValidate="AgeText" Display="Dynamic"
                              ErrorMessage="Age need to be between 20 to 50" MaximumValue="50"
                              MinimumValue="20" Style="color: #CC0000"&gt;*&lt;/asp:RangeValidator&gt;
                          &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                              ControlToValidate="AgeText" Display="Dynamic" ErrorMessage="Age is required"
                              Style="color: #CC0000"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td class="auto-style1" colspan="2"&gt;
                          &lt;asp:Button ID="SubmitButton" runat="server" OnClick="SubmitButtonClick"
                              Style="text-align: center" Text="Insert" /&gt;
                      &lt;/td&gt;
                      &lt;td class="auto-style7"&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
  
              &lt;asp:ValidationSummary ID="ValidationSummary1" runat="server"
                  Style="color: #CC0000" /&gt;
  
              &lt;asp:Label ID="SuccessMessage" runat="server" Text="" Visible="False"&gt;&lt;/asp:Label&gt;
  
          &lt;/div&gt;
          &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server"
              ConnectionString="&lt;%$ ConnectionStrings:ASPConnectionString %&gt;"
              SelectCommand="SELECT * FROM [Students]"&gt;&lt;/asp:SqlDataSource&gt;
      &lt;/form&gt;
  
      &lt;link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" /&gt;
      &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
              $(function () {
                  $("#dialog").dialog({
                      autoOpen: false,
                      show: {
                          effect: "blind",
                          duration: 1000
                      },
                      hide: {
                          effect: "explode",
                          duration: 1000
                      }
                  });
  
                  function showalert() {
                      $(document).ready(function () {
                          $("#dialog").dialog("open");
                      });
                  }
          /*        $("#opener").click(function () {
                      $("#dialog").dialog("open");
                  });*/
              });
  
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to open the dialog after postback and it runs the alert function after finished the insert. Can you help me thanks.
  I'm now getting showalert() is not defined.</p>