问题描述
我的ASP.net网站上有一个母版页.在这里,我有一个按钮.它将导航到wecomePage.这是背后的代码.
I have a Master page in my ASP.net web site. And here I have a Button. It will navigates to wecomePage. Here is the code behind.
protected void ImageButtonShortcut1_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("welcomePage.aspx", true);
//Server.Transfer("welcomePage.aspx", true);
}
现在我有一个继承于master之上的子页面.在子页面内部,我使用了一个具有 Requiredvalidation
的TextBox.
Now I have a childpage which inherits above master. Inside the child page I used a TextBox with Required validation
.
<asp:TextBox ID="TextBox_Model" runat="server"> </asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="TextBox_Model" ErrorMessage="Model Required"></asp:RequiredFieldValidator>
场景:当用户导航到上面的子页面并且未在该文本框中输入任何内容时,他试图按母版页"按钮以返回到 WelcomePage
.
Scenario : When User navigates to above child page and without entering anything to that Text box, he is trying to hit Master page Button for return to WelcomePage
.
很遗憾,由于用户尚未填写必填字段,因此不允许导航.我该如何克服这个问题?请帮我.谢谢.
Unfortunately It doesn't allow to navigate, since user hasn't filled the Required field. How can I overcome this problem? Please help me. Thank you.
推荐答案
似乎您未将ValidationGroup用于其对应Button的RequiredFieldValidator.尝试使用
It seems you are not using ValidationGroup for the RequiredFieldValidator for their correspondent Button. try using that
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ValidationGroup="WelcomePageTxtBox" ControlToValidate="TextBox_Model" ErrorMessage="Model Required"></asp:RequiredFieldValidator>
<asp:Button ID="Button2" runat="server" ValidationGroup="WelcomePageTxtBox" Text="Button" />
这篇关于在子页面中触发“必需的验证"时,MasterPage事件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!