如何在用户直接单击链接而不选择下拉列表时显示消息 [英] How to show a message when user directly click the link without selecting dropdownlist

查看:93
本文介绍了如何在用户直接单击链接而不选择下拉列表时显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的母版页中,我有三个下拉列表(州,区,区)和一些链接(学校,医院,报亭)。我已经插入了学校,医院的详细信息......通过将区域ID作为外键。现在,当我选择州区和区域时,它显示所选区域的学校医院的详细信息。现在的问题是,当我直接点击链接(学校,医院,巴士站)(不选择下拉列表)时,它显示错误(附近语法不正确) '=',da.Fill(ds);),我想显示一条消息,请选择你的区域

In my master page i have three dropdownlists(State,District,Area) and some links(Schools,Hospitals,Busstands).And i have inserted the details of schools,hospitals....by giving Area id as foreign key .Now when i select state district and area it displaying the details of schools hospitals of that selected area.Now the question is, when i click link(Schools,Hospitals,Busstands) directly( not selecting dropdownlist) it showing error (Incorrect syntax near '=' , da.Fill(ds);),i wants to show a message as PLEASE SELECT YOUR AREA

推荐答案

你可以使用requiredfieldvalidator并设置初始值作为区域下拉列表的默认值

检查文档中给出的示例代码 RequiredFieldValidator.InitialValue [ ^ ]

使用requiredfieldvalidator你可以检查输入而无需去服务器边验证。

如果你想在服务器端c#代码中做同样的事情;在从数据库中获取数据之前检查区域代码的值。如果它是空的,你可以显示消息并退出数据加载方法而不执行数据库选择语句
you can use requiredfieldvalidator and set the initial value as default value of the area drop down
check the sample codes given in the documentation RequiredFieldValidator.InitialValue[^]
by using requiredfieldvalidator you can check inputs without going to server side validation.
if you want to do the same in server side c# code; check the value of area code before you fetch the data from the database. if it is empty you can show message and exit the data loading method without executing database select statement


这篇关于如何在用户直接单击链接而不选择下拉列表时显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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