asp.net中的验证问题 [英] Problem with Validation in asp.net

查看:78
本文介绍了asp.net中的验证问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个网页,其中许多textbox.my问题我通过示例解释我有一个迭代号。当我在文本框中输入iteam no时,点击搜索按钮,其他文本框中的lyk compny名称,大小等由搜索Query.N填充其他用户必须填写的文本框。



问题是我在所有文本框中都放置了所需的验证,所以当我点击搜索btn它显示错误n搜索查询也没有工作(但如果我删除验证搜索查询工作)那么什么是错误请提我如何使用验证克服这个问题..

帮助我。



我的搜索查询是:


I have a webpage in which many textbox.my problem i explain through the example that i have an iteam no. of TV when i entered iteam no in textbox n click on search button other textbox feilds lyk compny name,size etc. filled by search Query.N also other textbox which user have to fill.

Problem is that i put required validation in all the textbox so when i click on search btn it displays error n search Query is also not worked(but if i removed validation search query is worked)so what is error pls mention n how do i overcome from this problem using validation..
help me.

my search query is:

SqlConnection con = new SqlConnection(_cnn1);
SqlCommand cmd = new SqlCommand("select * from iteamtable where iteam_id=@iteam_id", con);
cmd.Parameters.AddWithValue("@iteam_id", txtiteam_id.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
    txtname.Text = ds.Tables[0].Rows[0]["name"].ToString();
    txtmodel.Text = ds.Tables[0].Rows[0]["model"].ToString();
    txtSize.Text = ds.Tables[0].Rows[0]["size"].ToString();
}

推荐答案

Quote:

问题是我在所有文本框中都进行了必要的验证,所以当我点击搜索btn时它会显示错误n搜索查询也无效

Problem is that i put required validation in all the textbox so when i click on search btn it displays error n search Query is also not worked





如果您为所有文本框添加了必填字段,首先,当您单击按钮时,它将检查页面是否有效。您需要输入所有必填字段并单击搜索按钮,然后才能获得搜索结果。根据您的要求,iteam_id字段是唯一需要的文本框,其他字段是可选的。因此,使用验证器根据需要制作该文本框并删除所有其他文本框验证器



If you put required fields for all your text boxes,first it will check page is valid when you click on button. you need to enter all the required fields and click on search button, then only you get the search results. As per your requirement iteam_id field is the only text box which is required, others are optional. So make that text box as required by using validator and remove all other textbox validators


这篇关于asp.net中的验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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