RequiredFieldValidator
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="請輸入日期"></asp:RequiredFieldValidator>
// 群組化, 可設定
ValidationGroup="gp01"
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="存檔"
ValidationGroup="gp01" />
<asp:TextBox ID="txtdate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtdate" ErrorMessage="請輸入日期" ValidationGroup="gp01"></asp:RequiredFieldValidator>
// DropDownList ,用 InitialValue="0"來判斷
<asp:DropDownList
ID="DropDownList1" runat="server">
<asp:ListItem Value="0">請選擇...</asp:ListItem>
<asp:ListItem Value="0001">會議室1</asp:ListItem>
<asp:ListItem Value="0002">會議室2</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="DropDownList1" ErrorMessage="請選擇會議室..." InitialValue="0"
ValidationGroup="gp02"></asp:RequiredFieldValidator>
Display="None" // 屬性 ,不顯示出來,要配合 ValidationSummary 使用
ValidationSummary
ShowMessageBox="True" //屬性會變成彈跳訊息
ValidationGroup="group01" //屬性,設定群組
DisplayMode="List" //屬性,顯示方式,list會少了 - 符號
ShowSummary="False" //屬性,是否在網頁上顯示訊息
沒有留言:
張貼留言