如何将jQuery值保存到SQL数据库?

问题描述:

我有一个使用jQuery屏蔽文本框中数据的Web表单。当用户在文本框中输入一些数字时,它们会被屏蔽,然后被屏蔽到另一个文本框中。我想将未屏蔽的数据保存到数据库,但没有运气。当用户点击提交时,如何将文本框中未屏蔽的数据保存到数据库?



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									

(document).ready(function () {
(document).ready(function () {


.mask.definitions['~'] = \"[+-]\";
.mask.definitions['~'] = "[+-]";


(\"#TextBoxMaskTNUGSC\").mask('999,999,999,999');