验证控制问题
我有一个多视图,可以模拟具有不同类型选项的菜单。
多视图控件中的每个视图都包含一堆控件(列表框、标签等) 一切都工作得很好,直到我想实现验证控件。
例如,当我单击菜单时,viewA 将显示其控件。 我希望实现一个RequiredFieldValidator。
但问题是,如果我单击其他菜单选项(实际上是我的多视图中的其他视图),则会给出错误消息“请输入消息”,这是第一个菜单选项的第一个RequiredFieldValidator的错误消息(第一个视图)。
我的所有控件都以唯一的名称命名,因此 ControlToValidate="" 之间没有混淆,
当然这是不合适的,因为这些菜单选项是独立的。 这并不是我必须填写所有内容的意图,因为它毕竟是一个菜单,而不是我必须立即输入所有内容的表格。
我怎样才能在我的视图上有一个不考虑彼此的RequiredFieldValidator?
关于如何处理我的活动视图的一些代码
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
View activeView = (View)this.mvMultiview.FindControl(this.getViewFromRequest());
if (!(activeView == null))
{
this.mvMultiview.SetActiveView(activeView);
}
}
}
谢谢。
I have a multiview that simulates a menu with different kind of options.
Each view within the multiview control holds a bunch of controls (listbox, label, etc..)
Everything worked just fine, until i wanted to implement Validation control(s).
For example when i click on my menu viewA gets displayed with its controls.
There i wish to implement a RequiredFieldValidator.
But the problem is, if i click on a other menu option (which is in fact a other view in my multiview) then it gives the error message 'Please enter a message" which is the errorMessage of the first RequiredFieldValidator of the first menu option (first view).
All my controls are named with a unique name, so there is no mixup amongst the ControlToValidate=""
Offcourse this is not suitable, cause those menu choices are indepentant.
And its not the intention i have to fill in everything, cause its a menu afterall, and not a form where i have to enter everything at once.
How can i have a RequiredFieldValidator on my views that do not take each other in account?
Some code on how my active view is handled
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
View activeView = (View)this.mvMultiview.FindControl(this.getViewFromRequest());
if (!(activeView == null))
{
this.mvMultiview.SetActiveView(activeView);
}
}
}
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论