1
A
回答
10
使用與InitialValue財產,你不希望被選擇的默認項:
<asp:DropDownList ID="ddlItems" runat="server">
<asp:ListItem Text="-Day-" Value="-Day-"></asp:ListItem>
<asp:ListItem Text="Item 1" Value="Item 1"></asp:ListItem>
<asp:ListItem Text="Item 2" Value="Item 2"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1"
ErrorMessage="Validation Message !" ControlToValidate="ddlItems"
InitialValue="-Day-"></asp:RequiredFieldValidator>
1
你可以使用像這樣的CompareValidator:
<asp:DropDownList ID="ddlItems" runat="server">
<asp:ListItem Text="-Day-" Value="-1"></asp:ListItem>
<asp:ListItem Text="Item 1" Value="Item 1"></asp:ListItem>
<asp:ListItem Text="Item 2" Value="Item 2"></asp:ListItem>
</asp:DropDownList>
<asp:CompareValidator runat="server" ID="CompareFieldValidator1"
ErrorMessage="Validation Message !" ControlToValidate="ddlItems"
ValueToCompare="-1" Operator="NotEqual"></asp:CompareValidator>
-Edoode
相關問題
- 1. 的RequiredFieldValidator
- 2. Extending RequiredFieldValidator
- 3. RequiredFieldValidator不工作
- 4. asp.net - Listbox - InsertItemTemplate RequiredFieldValidator
- 5. RequiredFieldValidator + Button =回傳!
- 6. RequiredFieldValidator問題
- 7. RequiredFieldValidator幫助
- 8. RequiredFieldValidator和樣式
- 9. .net Calendar requiredFieldValidator
- 10. RequiredFieldValidator .net 2010
- 11. 的RequiredFieldValidator在Asp.net
- 12. ASP requiredfieldvalidator和jquery
- 13. ASP.net RequiredFieldValidator VisualStudio 2012
- 14. 禁用RequiredFieldvalidator
- 15. Wicket-RequiredFieldValidator for AjaxEditableLabel
- 16. ASP.NET中的RequiredFieldValidator
- 17. ASP C#的RequiredFieldValidator
- 18. RequiredFieldValidator不驗證
- 19. 「落後」的RequiredFieldValidator
- 20. RequiredFieldValidator限制回發
- 21. RequiredFieldValidator和OnClientClick一起
- 22. 繞過一個requiredfieldvalidator
- 23. 進度條和requiredfieldvalidator
- 24. ValidatorEnable不禁用requiredfieldvalidator
- 25. 如何查找Requiredfieldvalidator
- 26. 的RequiredFieldValidator提示ModalPopupExtender
- 27. requiredfieldvalidator與formview衝突
- 28. DropDownList和RequiredFieldValidator控件
- 29. ASP.NET隱藏在requiredfieldvalidator面板
- 30. asp.net通過RequiredFieldValidator驗證
冷靜,從來不知道的與InitialValue屬性。謝謝。 – 2009-04-16 12:46:52