You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You write the following code fragment.
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="updateLabels" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" />
<asp:Label ID="Label2" runat="server" />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Label id="Label3" runat="server" />
You need to ensure that when you click the btnSubmit Button control, each Label control value is asynchronously updatable.
Which code segment should you use?
A.
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)
Label1.Text = "Label1 updated value"
Label2.Text = "Label2 updated value"
Label3.Text = "Label3 updated value"
End Sub
B.
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)
Label1.Text = "Label1 updated value"
Label2.Text = "Label2 updated value"
ScriptManager1.RegisterDataItem(Label3, "Label3 updated value")
End Sub
C.
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)
ScriptManager1.RegisterDataItem(Label1, "Label1 updated value")
ScriptManager1.RegisterDataItem(Label2, "Label2 updated value")
Label3.Text = "Label3 updated value"
End Sub
D.
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)
Label1.Text = "Label1 updated value"
Label2.Text = "Label2 updated value"
ScriptManager1.RegisterAsyncPostBackControl(Label3)
Label3.Text = "Label3 updated value"
End Sub
Explanation:
Use the RegisterDataItem method to send data from the server to the client during asynchronous postbacks, regardless of whether the control receiving the data is inside an UpdatePanel control.Use RegisterAsyncPostBackControl for Registers a control as a trigger for asynchronous postbacks.