PrepAway - Latest Free Exam Questions & Answers

Which code segment should you add to the DayParameter class?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You plan to add a custom parameter in the SqlDataSource control.
You write the following code fragment.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" InsertCommand="INSERT INTO [Employee] ([Field1], [Field2], [PostedDate]) VALUES (@Field1, @Field2, @PostedDate)"> <InsertParameters>
<asp:Parameter Name="Field1" />
<asp:Parameter Name="Field2" />
<custom:DayParameter?Name="PostedDate" />
</InsertParameters>
</asp:SqlDataSource>
You write the following code segment to create a custom parameter class.

Public Class DayParameter
Inherits Parameter
End Class

You need to ensure that the custom parameter returns the current date and time.
Which code segment should you add to the DayParameter class?

PrepAway - Latest Free Exam Questions & Answers

A.
Protected Sub New()
MyBase.New("Value", TypeCode.DateTime, DateTime.Now.ToString())
End Sub

B.
Protected Overrides Sub LoadViewState(savedState As Object)
DirectCast(savedState, StateBag).Add("Value", DateTime.Now)
End Sub

C.
Protected Overrides Function Evaluate(context As HttpContext, control As Control) As Object
Return DateTime.Now
End Function

D.
Protected Overrides Function Clone() As Parameter
Dim pm As Parameter = New DayParameter()
pm.DefaultValue = DateTime.Now
Return pm
End Function


Leave a Reply