title: Want to show value of variable in alert box
body: <p>I want to show the value of the variable in Alert box so please give me suggestion for that. Here is my code.</p>
  
  <pre><code>public partial class WebForm1 : System.Web.UI.Page
       {
          int sum3; 
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              { 
                  DataTable dTable = new DataTable("mainTable");
                   DataColumn Name = new DataColumn("Name");
                  dTable.Columns.Add(Name);
                   DataColumn Marks = new DataColumn("Marks");
                  dTable.Columns.Add(Marks); 
                  DataColumn Marks2 = new DataColumn("Marks2");
                  dTable.Columns.Add(Marks2); 
                  DataColumn Total = new DataColumn("Total");
                  dTable.Columns.Add(Total); 
                  int sum = 0;
                  int sum2 = 0; 
                  DataRow dRow = null;
                  for (int i = 0; i &lt; 5; i++)
                  {
                      dRow = dTable.NewRow();
                      dRow["Name"] = i + " - Sagar";
                      dRow["Marks"] = i;
                      sum += i;
                      dRow["Marks2"] = i + 5;
                      sum2 += i + 5;
                      dRow["Total"] = i + i + 5;
                      sum3 += i + i + 5;
                      dTable.Rows.Add(dRow);
                  }
                   Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showAlert(" + sum3.ToString() + ");", true);
  
                         aspDataGrid.DataSource = dTable;
                  aspDataGrid.DataBind();
              }
          }
  
          protected void btn_Submit_Click(object sender, EventArgs e)
          {
              marks1.Text = "Total Marks : " + sum3.ToString();
              Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showAlert(" + sum3.ToString() + ");", true);
          }
  }
  </code></pre>
  
  <p>Thanks in advance.</p>