我正在使用asp.net网络表单创建网站。我在表单中添加了对字段的验证(asp:RequiredFieldValidator),我在页面上使用了多语言,如下所示:
我有这样的链接按钮:
<asp:LinkButton ID="lnkSetEnglish" runat="server" CommandArgument="en-GB" OnClick="RequestLanguageChange_Click">
<img src="Images/logos/en.png" alt="English" />
</asp:LinkButton>
功能
protected void RequestLanguageChange_Click(object sender, EventArgs e)
{
ImageButton senderLink = sender as ImageButton;
HttpCookie cookie = new HttpCookie("CultureInfo");
cookie.Value = senderLink.CommandArgument;
Response.Cookies.Add(cookie);
//Set the culture and reload the page for immediate effect.
//Future effects are handled by Global.asax
Thread.CurrentThread.CurrentCulture = new CultureInfo(senderLink.CommandArgument);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(senderLink.CommandArgument);
Server.Transfer(Request.Path);
}
我现在有问题验证。当我在与验证字段的联系表单上并且此字段为空时,当我尝试通过单击链接中的图像来更改语言,而不是更改站点的语言时,我有来自验证的commant。我能在这做什么?
祝你好运, 达格纳
答案 0 :(得分:1)
在LinkButton上将CausesValidation设置为false