簡體   English   中英

在ASP中回發后驗證器消息消失

[英]Validator message disappeared after postback in asp

當我單擊提交按鈕而不輸入數據時,錯誤消息出現在必填字段。 但是,當我從單選按鈕,由於其自動回消息選擇消失,而我想這個消息顯示,直到我在字段中輸入的數據。

<asp:TextBox ID="contactName" runat="server" CssClass="texrbox" Enabled="false"></asp:TextBox>
<asp:RequiredFieldValidator ID="nameValidator" runat="server" ErrorMessage="Name Required" ControlToValidate="contactName" Display="Dynamic" ForeColor="Red" Text="*"></asp:RequiredFieldValidator>

在單選按鈕導致回發之前,此方法工作正常。

<asp:RadioButtonList ID="contact" runat="server" RepeatDirection="Horizontal" CausesValidation="false" ForeColor="Black" OnSelectedIndexChanged="contact_SelectedIndexChanged" AutoPostBack="true">
     <asp:ListItem Text="Submitter" Value="Submitter"></asp:ListItem>
     <asp:ListItem Text="Following" Value="Following"></asp:ListItem>
</asp:RadioButtonList>

現在,請幫助我如何使用回發 ,並且消息也不會消失。

在頁面回發時,在頁面加載時執行此操作。

 Page.Validate();
  if (Page.IsValid)
  {
     //TO DO
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM