Which code fragment should you add to the Web page?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You add a TextBox control named TextBox1.
You write the following code segment for validation.

Protected Sub ServerValidate(source As Object, args As ServerValidateEventArgs)
Dim dt As DateTime = [String].IsNullOrEmpty(args.Value)
DateTime.Now(Convert.ToDateTime(args.Value))
args.IsValid = (DateTime.Now – dt).Days < 10
End Sub

You need to validate the value of TextBox1.
Which code fragment should you add to the Web page?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You add a TextBox control named TextBox1.
You write the following code segment for validation.

Protected Sub ServerValidate(source As Object, args As ServerValidateEventArgs)
Dim dt As DateTime = [String].IsNullOrEmpty(args.Value)
DateTime.Now(Convert.ToDateTime(args.Value))
args.IsValid = (DateTime.Now – dt).Days < 10
End Sub

You need to validate the value of TextBox1.
Which code fragment should you add to the Web page?

A.
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1" ValidateEmptyText="True" onservervalidate="CustomValidator1_ServerValidate"> </asp:CustomValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server" Type="Date" EnableClientScript="true" ControlToValidate="TextBox1" Operator="DataTypeCheck" >
</asp:CompareValidator>

B.
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1" ValidateEmptyText="True" onservervalidate="CustomValidator1_ServerValidate"> </asp:CustomValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"ControlToValidate="TextBox1" InitialValue="<%= DateTime.Now; %>" >
</asp:RequiredFieldValidator>

C.
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1" ValidateEmptyText="True" onservervalidate="CustomValidator1_ServerValidate"> </asp:CustomValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server" Type="Date" EnableClientScript="true" ControlToValidate="TextBox1" ValueToCompare="<%= DateTime.Now; %>"> </asp:CompareValidator>

D.
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1" ValidateEmptyText="True" onservervalidate="CustomValidator1_ServerValidate"> </asp:CustomValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" EnableClientScript="false" InitialValue="<%= DateTime.Now; %>" > </asp:RequiredFieldValidator>



Leave a Reply 0

Your email address will not be published. Required fields are marked *