RadAjaxManager problem when showing/hiding control on page loading

Posted by Lukasz Lysik on Stack Overflow See other posts from Stack Overflow or by Lukasz Lysik
Published on 2010-06-15T08:18:54Z Indexed on 2010/06/15 8:22 UTC
Read the original article Hit count: 405

Filed under:
|

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_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
    SetupVisibility()
End Sub

The problem occurs in such a scenario:

  1. SetupVisibility() hides textbox and label while page is loaded.
  2. I change value on ddlTest dropdown list.
  3. 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?

© Stack Overflow or respective owner

Related posts about telerik

Related posts about radajaxmanager