如何处理服务器端的文本框值 [英] How to Handle textbox values on sever side

查看:90
本文介绍了如何处理服务器端的文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个文本框。

在textbox1和textbox2中我输入了一个数字赞 - >

I have three textboxes.
In textbox1 and in textbox2 i entered a number Like ->

Textbox1-0123456789
Textbox2-0123-456-789
Textboxe3-789-568-789







现在在服务器端,即在aspx.cs页面上我需要检查数字是否相同,只有一个不同的数字从textbox1和textbox2将保存在数据库中,Textboxe3值将被保存,因为Textbox3值不同




Now on server side i.e on aspx.cs page i need to check the numbers is it same or not and only one distinct number from textbox1 and textbox2 will be saved in database and Textboxe3 value will be saved because Textbox3 value is different

推荐答案

0 down vote accept





如果我们申请替换( - ,),而不是从每个文本框中删除破折号。数字与textbox1-0123456789相同textbox2 = 0123-456-789 textbox3 = 678-908-999



比替换将删除textbox3中的破折号也是我们不想要的。所以为此,我们必须申请linq的不存在操作。



列出strMobileNos =新列表();



正则表达式re =新的正则表达式(@\d {10} | \d {3} \ * * -\ * * \d {3} \ s * -\ * * \\ d {4});

!strMobileNos.Exists(l => l.Replace( - ,)== Request.Form [txtMobNo2]。替换(Mobile2 ,。).Replace( - ,))
0 down vote accept


If we apply replace("-","") than from every textbox it will remove dash.The number which is same like in textbox1-0123456789 textbox2=0123-456-789 textbox3=678-908-999

than replace will remove dash from textbox3 also which we dont want. so For this we have to apply not exists operation of linq.

List strMobileNos = new List();

Regex re = new Regex(@"\d{10}|\d{3}\s*-\s*\d{3}\s*-\s*\d{4}");
!strMobileNos.Exists(l => l.Replace("-", "") == Request.Form["txtMobNo2"].Replace("Mobile2", "").Replace("-", ""))


这篇关于如何处理服务器端的文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆