I have a web form that uses jQuery to mask the data in the textbox. When a user enters some numbers into textbox they are masked and then unmasked into another textbox. I want to save the unmasked data to the database but right no luck. How can I save the unmasked data in the textboxes to the database when the user clicks submit?
<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation = "false" CodeBehind="Gradrate.aspx.cs" Inherits="SACSCOCLogin1._1.Gradrate" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Graduation Rate Information</title>
<script src="Jquery Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="Jquery Scripts/jquery.maskedinput.js" type="text/javascript"></script>
<script type='text/javascript'>
$(document).ready(function () {
$.mask.definitions['~'] = "[+-]";
$("#TextBoxMaskTNUGSC").mask('999,999,999,999');
$("#TextBoxMaskTNUGSCD").mask('999,999,999,999');
$("#TextBoxMaskTTOUG").mask('999,999,999,999');
$("#TextBoxMaskTNGSC").mask('999,999,999,999');
$("#TextBoxMaskTNGSCD").mask('999,999,999,999');
$("#TextBoxMaskTTOG").mask('999,999,999,999');
$("#TextBoxMaskTNUGSC").blur(function () {
$("#TextBoxTNUGSC").val(" " + $(this).mask());
$("#TextBoxMaskTNUGSCD").blur(function () {
$("#TextBoxTNUGSCD").val(" " + $(this).mask());
$("#TextBoxMaskTTOUG").blur(function () {
$("#TextBoxTTOUG").val(" " + $(this).mask());
$("#TextBoxMaskTNGSC").blur(function () {
$("#TextBoxTNGSC").val(" " + $(this).mask());
$("#TextBoxMaskTNGSCD").blur(function () {
$("#TextBoxTNGSCD").val(" " + $(this).mask());
$("#TextBoxMaskTTOG").blur(function () {
$("#TextBoxTTOG").val(" " + $(this).mask());
}).dblclick(function () {
$(this).unmask();
});
});
});
});
});
});
});
</script>
<style type="text/css">
.style1
{
width: 585px;
height: 137px;
}
.style2
{
font-size: x-large;
text-align: center;
}
.style3
{
width: 100%;
}
.style4
{
width: 520px;
}
.style5
{
width: 188px;
text-align: center;
}
.style9
{
font-size: x-large;
text-decoration: underline;
text-align: center;
}
.style10
{
width: 189px;
}
.style11
{
font-weight: bold;
text-align: center;
}
.style13
{
width: 73px;
font-size: large;
}
.style15
{
font-weight: bold;
font-size: x-large;
}
.style16
{
width: 673px;
}
.style17
{
color: #FF0000;
font-size: large;
text-align: center;
}
.style18
{
width: 131px;
}
.style19
{
width: 190px;
text-align: center;
}
.style20
{
width: 190px;
text-align: center;
}
.style21
{
width: 188px;
text-align: center;
}
.style23
{
font-weight: bold;
font-size: large;
}
.style24
{
width: 653px;
}
.style25
{
width: 204px;
}
.style26
{
font-weight: bold;
text-align: center;
}
.style27
{
width: 416px;
text-align: center;
}
.style28
{
width: 491px;
text-align: right;
}
.style29
{
text-align: left;
}
.style30
{
font-weight: bold;
}
.style31
{
text-align: center;
}
</style>
</head>
<body background="Images/bkg-blu.jpg">
<form id="form1" runat="server">
<div style="text-align: center">
<img alt="" class="style1" src="Images/buildout_header.jpg" /></div>
<p>
<asp:TextBox ID="TextBoxINST_ID" runat="server" Enabled="False" ReadOnly="True"
Visible="False"></asp:TextBox>
<asp:TextBox ID="TextBoxaccessLevel" runat="server"
Enabled="False" ReadOnly="True" Visible="False"></asp:TextBox>
</p>
<p class="style2">
</p>
<div class="style9">
Graduation Rate Information<br />
</div>
<p class="style17">
"Note, if your institution reports more than one set of cohorts using
more than one Unit ID, Please enter the Unit ID into the textbox first before
anything else. Then enter the information needed. This form will reset once you
have clicked the Submit button."</p>
<p class="style17">
</p>
<table class="style3">
<tr>
<td style="text-align: center">
<asp:Label ID="lblSchool" runat="server" CssClass="style15"></asp:Label>
</td>
</tr>
</table>
<table class="style3">
<tr>
<td class="style16" style="text-align: right">
<asp:Label ID="lblCity" runat="server" CssClass="style23"></asp:Label>
,</td>
<td>
<asp:Label ID="lblState" runat="server" CssClass="style23"></asp:Label>
</td>
</tr>
</table>
<br />
Unit ID (Six-Digit IPEDS institution number):<br />
<table class="style3">
<tr>
<td class="style13">
Unit ID</td>
<td class="style18">
<asp:TextBox ID="TextBoxUNITID" runat="server" AutoPostBack="True"
ontextchanged="TextBoxUNITID_TextChanged" Width="180px">0</asp:TextBox>
</td>
<td class="style24">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBoxUNITID" CssClass="style30"
ErrorMessage="You Must Enter a Unit ID" ForeColor="Red"
ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</td>
<td>
Today's Date</td>
<td class="style25">
<asp:TextBox ID="TextBoxDATE" runat="server" Width="180px" CssClass="style11"
Enabled="False" ReadOnly="True" style="text-align: center"></asp:TextBox>
</td>
<td>
<asp:Label ID="lblTime" runat="server" style="font-weight: 700"></asp:Label>
</td>
</tr>
<tr>
<td class="style13">
</td>
<td class="style18">
</td>
<td class="style24">
</td>
</tr>
</table>
<table class="style3">
<tr>
<td class="style4">
</td>
<td class="style5">
</td>
<td class="style19">
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
</td>
<td class="style21">
<asp:Label ID="lblLYear" runat="server" CssClass="style30">Fall 2013</asp:Label>
</td>
<td class="style20">
<asp:Label ID="lblYear" runat="server" CssClass="style30" Text="Fall 2014"></asp:Label>
<asp:Label ID="lblYear1" runat="server" CssClass="style30" Text="2014"
Visible="False"></asp:Label>
</td>
<td>
</td>
</tr>
</table>
<table class="style3">
<tr>
<td class="style4">
Associates / Two-Year Program</td>
<td class="style5">
</td>
<td class="style10">
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
1. Total Number of Students in the Cohort</td>
<td class="style5">
<asp:TextBox ID="TextBoxLYTNUGSC" runat="server" Width="180px"
ReadOnly="True" Enabled="False"></asp:TextBox>
</td>
<td class="style10">
<asp:TextBox ID="TextBoxMaskTNUGSC" runat="server" Width="180px">0</asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="TextBoxTNUGSC" CssClass="style30"
ErrorMessage="You Must Enter Total Students Cohort" ForeColor="Red"
ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style4">
2. Total Number of Students Completed within 150% of Time of Degree</td>
<td class="style5">
<asp:TextBox ID="TextBoxLYTNUGSCD" runat="server" Width="180px"
ReadOnly="True" Enabled="False"></asp:TextBox>
</td>
<td class="style10">
<asp:TextBox ID="TextBoxMaskTNUGSCD" runat="server" Width="180px">0</asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server"
ControlToValidate="TextBoxTNUGSCD" CssClass="style30"
ErrorMessage="You Must Enter Total Students Completed" ForeColor="Red"
ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style4">
3. Total Transfers Out</td>
<td class="style5">
<asp:TextBox ID="TextBoxLYTTOUG" runat="server" Width="180px"
ReadOnly="True" Enabled="False"></asp:TextBox>
</td>
<td class="style10">
<asp:TextBox ID="TextBoxMaskTTOUG" runat="server" Width="180px">0</asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server"
ControlToValidate="TextBoxTTOUG" CssClass="style30"
ErrorMessage="You Must EnterTotal Transfers" ForeColor="Red"
ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style4">
Baccalaureate / Four-Year Program</td>
<td class="style5">
</td>
<td class="style10">
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
4. Total Number of Students in the Cohort</td>
<td class="style5">
<asp:TextBox ID="TextBoxLYTNGSC" runat="server" Width="180px"
ReadOnly="True" Enabled="False"></asp:TextBox>
</td>
<td class="style10">
<asp:TextBox ID="TextBoxMaskTNGSC" runat="server" Width="180px">0</asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server"
ControlToValidate="TextBoxTNGSC" CssClass="style30"
ErrorMessage="You Must Enter Total Students Cohort" ForeColor="Red"
ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style4">
5. Total Number of Students Completed within 150% of Time of Degree</td>
<td class="style5">
<asp:TextBox ID="TextBoxLYTNGSCD" runat="server" Width="180px"
ReadOnly="True" Enabled="False"></asp:TextBox>
</td>
<td class="style10">
<asp:TextBox ID="TextBoxMaskTNGSCD" runat="server" Width="180px">0</asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server"
ControlToValidate="TextBoxTNGSCD" CssClass="style30"
ErrorMessage="You Must Enter Total Students Completed" ForeColor="Red"
ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style4">
6. Total
Transfers Out</td>
<td class="style5">
<asp:TextBox ID="TextBoxLYTTOG" runat="server" Width="180px"
ReadOnly="True" Enabled="False"></asp:TextBox>
</td>
<td class="style10">
<asp:TextBox ID="TextBoxMaskTTOG" runat="server" Width="180px">0</asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator7" runat="server"
ControlToValidate="TextBoxTTOG" CssClass="style30"
ErrorMessage="You Must EnterTotal Transfers" ForeColor="Red"
ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</td>
</tr>
</table>
<table class="style3">
<tr>
<td class="style29">
<asp:TextBox ID="TextBoxTNUGSC" runat="server" Width="180px" Enabled="False"></asp:TextBox>
</td>
<td class="style29">
<asp:TextBox ID="TextBoxTNUGSCD" runat="server" Width="180px" Enabled="False"></asp:TextBox>
</td>
<td class="style29">
<asp:TextBox ID="TextBoxTTOUG" runat="server" Width="180px" Enabled="False"></asp:TextBox>
</td>
<td class="style29">
<asp:TextBox ID="TextBoxTNGSC" runat="server" Width="180px" Enabled="False"></asp:TextBox>
</td>
<td class="style29">
<asp:TextBox ID="TextBoxTNGSCD" runat="server" Width="180px" Enabled="False"></asp:TextBox>
</td>
<td class="style29">
<asp:TextBox ID="TextBoxTTOG" runat="server" Width="180px" Enabled="False"></asp:TextBox>
</td>
</tr>
</table>
<br />
<br />
<table class="style3">
<tr>
<td class="style28">
<asp:Button ID="Submit" runat="server" Text="Submit" Width="100px"
onclick="Submit_Click" CssClass="style26" Height="26px" />
</td>
<td style="text-align: center" class="style27">
<asp:Button ID="Menu" runat="server" CssClass="style26" onclick="Menu_Click"
Text="Menu" Width="100px" CausesValidation="False" />
</td>
<td class="style29">
<asp:Button ID="Print" runat="server" Text="Print" Width="100px"
onclick="Print_Click" CssClass="style26" CausesValidation="False" />
</td>
</tr>
</table>
</form>
</body>
</html>
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing.Printing;
using System.IO;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace SACSCOCLogin1._1
{
public partial class Gradrate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBoxUNITID.Focus();
this.TextBoxDATE.Text = DateTime.Today.ToString("dd-MMM-yy");
this.lblTime.Text = System.DateTime.Now.ToShortTimeString();
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con.Open();
SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con2.Open();
TextBoxINST12_ID.Text = Session["inst_id12"].ToString();
SqlCommand scmd = new SqlCommand("Select INST12_ID, LongName, City, State from TableCOCINST where INST_ID = '" + TextBoxINST12_ID.Text + "'", con);
SqlCommand scmd2 = new SqlCommand("Select INST12_ID, accessLevel2 from Tableopen where INST12_ID = '" + TextBoxINST12_ID.Text + "'", con2);
SqlDataReader dr = scmd.ExecuteReader();
SqlDataReader dr2 = scmd2.ExecuteReader();
if (dr.Read())
if (dr2.Read())
{
TextBoxaccessLevel2.Text = dr2["accessLevel"].ToString();
lblSchool.Text = dr["LongName"].ToString();
lblCity.Text = dr["City"].ToString();
lblState.Text = dr["State"].ToString();
}
dr.Close();
con.Close();
dr2.Close();
con2.Close();
}
protected void Submit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("Insert into Table3 (INST12_ID, UNITID2, ASTUDENTS, ACOMPLETED, ATRANSFERS, BSTUDENTS, BCOMPLETED, BTRANSFERS, YEAR, DATE) values (@INST_ID, @UNITID, @ASTUDENTS, @ACOMPLETED, @ATRANSFERS, @BSTUDENTS, @BCOMPLETED, @BTRANSFERS, @YEAR, @DATE); Insert into Table3(INST_ID, UNITID, ASTUDENTS, ACOMPLETED, ATRANSFERS, BSTUDENTS, BCOMPLETED, BTRANSFERS, YEAR, DATE) values (@INST_ID, @UNITID, @ASTUDENTS, @ACOMPLETED, @ATRANSFERS, @BSTUDENTS, @BCOMPLETED, @BTRANSFERS, @YEAR, @DATE);", con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@ASTUDENTS", TextBoxTNUGSC.Text);
cmd.Parameters.AddWithValue("@ACOMPLETED", TextBoxTNUGSCD.Text);
cmd.Parameters.AddWithValue("@ATRANSFERS", TextBoxTTOUG.Text);
cmd.Parameters.AddWithValue("@BSTUDENTS", TextBoxTNGSC.Text);
cmd.Parameters.AddWithValue("@BCOMPLETED", TextBoxTNGSCD.Text);
cmd.Parameters.AddWithValue("@BTRANSFERS", TextBoxTTOG.Text);
cmd.Parameters.AddWithValue("@YEAR", lblYear1.Text);
cmd.Parameters.AddWithValue("@DATE", TextBoxDATE.Text);
cmd.Parameters.AddWithValue("@UNITID", TextBoxUNITID2.Text);
cmd.Parameters.AddWithValue("@INST_ID", TextBoxINST12_ID.Text);
cmd.ExecuteNonQuery();
con.Close();
if (Page.IsValid)
{
SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con2.Open();
SqlCommand level = new SqlCommand("select accessLevel, INST12_ID from Tableopen where INST12_ID = @INST12_ID AND accessLevel2 = @accessLevel2", con2);
level.Parameters.Add(new SqlParameter("INST12_ID", TextBoxINST12_ID.Text));
level.Parameters.Add(new SqlParameter("accessLevel2", TextBoxaccessLevel2.Text));
SqlDataReader reader = level.ExecuteReader();
DataTable dt1 = new DataTable();
dt1.Load(reader);
foreach (DataRow dr1 in dt1.Rows)
{
int returnedLevel = Convert.ToInt32(dr1[0].ToString());
int accessLevel2 = Convert.ToInt32(dr1[1].ToString());
Session["accessLevel2"] = accessLevel;
if (returnedLevel == 1)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts Please Click on the Graduation Rate Link to Enter another Cohort');location.href='FormAPublic.aspx';", true);
}
else if (returnedLevel == 2)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts Please Click on the Graduation Rate Link to Enter another Cohort');location.href='FormCPrivateNon.aspx';", true);
}
else if (returnedLevel == 3)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts Please Click on the Graduation Rate Link to Enter another Cohort');location.href='FormDPrivateFor.aspx';", true);
}
else if (returnedLevel == 11)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts Please Click on the Graduation Rate Link to Enter another Cohort');location.href='FormAPublicL.aspx';", true);
}
else if (returnedLevel == 21)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts Please Click on the Graduation Rate Link to Enter another Cohort');location.href='FormCPrivateNonL.aspx';", true);
}
else if (returnedLevel == 31)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts Please Click on the Graduation Rate Link to Enter another Cohort');location.href='FormDPrivateForL.aspx';", true);
}
else if (returnedLevel == 7)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts Please Click on the Graduation Rate Link to Enter another Cohort');location.href='CEOPage.aspx';", true);
}
}
con2.Close();
}
}
protected void TextBoxUNITID2_TextChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con.Open();
if (true)
{
SqlCommand level = new SqlCommand("select UNITID2, INST12_ID from Table12 where UNITID2 = @UNITID2 AND INS12T_ID = @INST12_ID", con);
level.Parameters.Add(new SqlParameter("UNITID2", TextBoxUNITID.Text));
level.Parameters.Add(new SqlParameter("INST12_ID", TextBoxINST_ID.Text));
SqlCommand scmd = new SqlCommand("Select INST_ID, UNITID, ASTUDENTS, ACOMPLETED, ATRANSFERS, BSTUDENTS, BCOMPLETED, BTRANSFERS from Table4 where UNITID = @TextBoxUNITID", con);
scmd.Parameters.Add(new SqlParameter("@TextBoxUNITID2", TextBoxUNITID.Text));
SqlDataReader dr = scmd.ExecuteReader();
if (dr.Read())
{
TextBoxLYTNUGSC.Text = dr["ASTUDENTS"].ToString();
TextBoxLYTNUGSCD.Text = dr["ACOMPLETED"].ToString();
TextBoxLYTTOUG.Text = dr["ATRANSFERS"].ToString();
TextBoxLYTNGSC.Text = dr["BSTUDENTS"].ToString();
TextBoxLYTNGSCD.Text = dr["BCOMPLETED"].ToString();
TextBoxLYTTOG.Text = dr["BTRANSFERS"].ToString();
}
dr.Close();
con.Close();
}
}
protected void Print_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('ReportFormGrad.aspx','PrintMe','height=650px,width=950px,scrollbars=1');</script>");
}
protected void Menu_Click(object sender, EventArgs e)
{
SqlConnection con5 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con5.Open();
SqlCommand level = new SqlCommand("select accessLevel, INST_ID from Tableopen where INST_ID = @INST_ID AND accessLevel = @accessLevel", con5);
level.Parameters.Add(new SqlParameter("INST_ID", TextBoxINST_ID.Text));
level.Parameters.Add(new SqlParameter("accessLevel", TextBoxaccessLevel.Text));
SqlDataReader reader = level.ExecuteReader();
DataTable dt1 = new DataTable();
dt1.Load(reader);
foreach (DataRow dr1 in dt1.Rows)
{
int returnedLevel = Convert.ToInt32(dr1[0].ToString());
int accessLevel = Convert.ToInt32(dr1[1].ToString());
Session["accessLevel"] = accessLevel;
if (returnedLevel == 1)
{
Response.Redirect("FormAPublic.aspx");
}
else if (returnedLevel == 2)
{
Response.Redirect("FormCPrivateNon.aspx");
}
else if (returnedLevel == 3)
{
Response.Redirect("FormDPrivateFor.aspx");
}
else if (returnedLevel == 11)
{
Response.Redirect("FormAPublicL.aspx");
}
else if (returnedLevel == 21)
{
Response.Redirect("FormCPrivateNonL.aspx");
}
else if (returnedLevel == 31)
{
Response.Redirect("FormDPrivateForL.aspx");
}
else if (returnedLevel == 7)
{
Response.Redirect("CEOPage.aspx");
}
con5.Close();
}
}
}
}