I have the webform with dropdown list, label and textbox. Like below:
<asp:DropDownList ID="ddlTest" runat="server" AutoPostBack="true">
</asp:DropDownList>
<asp:Label ID="lblTest" runat="server" Text="Some text">
</asp:Label>
<asp:TextBox ID="edtTest" runat="server">
</asp:TextBox>
I want to show/hide label and text box depending on the value selected on dropdown list. So I've added RadAjaxManader:
<rad:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<rad:AjaxSetting AjaxControlID="ddlTest">
<UpdatedControls>
<rad:AjaxUpdatedControl ControlID="lblTest" />
<rad:AjaxUpdatedControl ControlID="edtTest" />
</UpdatedControls>
</rad:AjaxSetting>
</AjaxSettings>
</rad:RadAjaxManager>
and procedure "SetupVisibility" which takes value from the dropdown list, does some walidations and desides whether to show or hide the label and the text box. When I use the procedure like this:
Protected Sub ddlTest_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlTest.SelectedIndexChanged
SetupVisibility()
End Sub
it works good, but now I want to call SetupVisibility when the page is loaded:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SetupVisibility()
End Sub
The problem occurs in such a scenario:
- SetupVisibility() hides textbox and label while page is loaded.
- I change value on ddlTest dropdown list.
- SetupVisibility() wants to show textbox and label, but then I get the error:
Microsoft JScript - runtime error: Cannot update control with ID: ctl00_CPH1_lblTest. The control does not exist.
Where is the problem?