本文介绍了如何将unmask数据从文本框保存到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在使用VS 2010和C#。我在表单上有六个文本框。我还有jQuery在用户输入数据时屏蔽文本框。我想要做的是从textrboxes获取数据的值到我的SQL数据库。当用户将数据输入文本框时,使用jQuery插件屏蔽数字。然后用户点击标签或点击下一个文本框。 textbox1中的蒙版值未被屏蔽并显示在textbox1a中。我试图将textbox1a中的值插入数据库,但没有运气。有人可以帮助我并告诉我我在做什么吗?I am using VS 2010 with C#. I have six textboxes on the form. I also have jQuery to mask the textboxes when the user enters their data. What I am trying to do is to get the value of the data from the textrboxes to my SQL database. When the user enters the data into the textbox the numbers are masked by using the jQuery plugin. Then the user hits tab or clicks to the next textbox. The masked value in textbox1 is unmasked and shown in textbox1a. I am trying to insert the value in textbox1a to the database but with no luck. Can someone please help me and tell me what I am doing wring?<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").html(" " + $(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(); }); }); }); }); }); });}); 这是我将C#代码插入数据库:Here is my C# code to insert it into the database:protected void Submit_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("Insert into Table1 (INST12_ID, UNITID, ASTUDENTS, ACOMPLETED, ATRANSFERS, BSTUDENTS, BCOMPLETED, BTRANSFERS, YEAR, DATE) values (@INST_ID, @UNITID, @ASTUDENTS, @ACOMPLETED, @ATRANSFERS, @BSTUDENTS, @BCOMPLETED, @BTRANSFERS, @YEAR, @DATE); Insert into Table1a (INST12_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", TextBoxUNITID.Text); cmd.Parameters.AddWithValue("@INST_ID", TextBoxINST_ID.Text); cmd.ExecuteNonQuery(); con.Close();}推荐答案 这篇关于如何将unmask数据从文本框保存到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-11 17:35