2009-06-01 59 views

回答

1

請提供一些示例代碼和更好地解釋「asp.net事件的服務器控件無法工作」的含義。

在此期間,這裏的一些sample code如何Page_ClientValidate(validationGroup)應使用:

<asp:TextBox runat="server" ID="tbHours" Width="50px"></asp:TextBox> 
<asp:RequiredFieldValidator ID="rvalAddHours" runat="server" ControlToValidate="tbHours" ValidationGroup="AddEntry" ErrorMessage="* Hours Required" Display="Dynamic"></asp:RequiredFieldValidator> 
<asp:RangeValidator ID="rgValAddHours" runat="server" ControlToValidate="tbHours" ValidationGroup="AddEntry" ErrorMessage="* Hours Must Be 0-24" Display="Dynamic" Type="Double" MinimumValue="0" MaximumValue="24"></asp:RangeValidator> 
<asp:Button ID="btnAddEntry" runat="server" OnClientClick="ValidateAndAddNewEntry(); return false;" CausesValidation="true" ValidationGroup="AddEntry" Text="Create" /> 

<script type="text/javascript> 
function ValidateAndAddNewEntry() { 
    var res = Page_ClientValidate("AddEntry");  
    if (res == true) { 
     //Do work 
    } 
} 
</script> 
相關問題