ClientID not being replaced

2 posts, 1 answers
  1. Lenny_shp
    Lenny_shp avatar
    343 posts
    Member since:
    Jul 2006

    Posted 12 Jan 2010 Link to this post

                            <asp:RadioButtonList ID="rdoOffer" onclick="alert('<%= rdoOffer.ClientID %>');" 
                                <asp:ListItem Text="Yes" Value="Y"></asp:ListItem> 
                                <asp:ListItem Text="No" Value="N"></asp:ListItem> 

    When putting RadScriptBlock around RadioButtonList, I get an error msg that there is an invalid character.

    This snippet is inside an User Control ascx and the main page has AjaxManager.

    I can use RadScriptBlock around a javascript but how do I get it to work in the onClick of the control?
    I don't want to create a js function for each control that I need to use it.   I would like to pass the clientID of the control to the generic function.

    Right now I used AutoPostback="true" but the roundtrip cost is 50k compressed and there is a slight delay.
    All I wanted to do in OnClick is to make another <div> section visible or hidden based on the choices.
    In validation code I check if the controls in <div> is visibile if so apply validation.

    Is it possible to use client script to alter the <div>'s visibility and also have the visibility carry back to server side code on the next autopostback?
  2. Answer
    Iana Tsolova
    Iana Tsolova avatar
    3388 posts

    Posted 15 Jan 2010 Link to this post

    Hello Lenny_shp,

    I tried following your scenario in order to replicate the mentioned error but to no avail.
    However I suggest that you use regular javascript functions in order to achieve your goal as the server code blocks you added in the RadioButtonList might not be evaluated properly.
    Additionally, to make sure your pages would work as expected withe RadAjax, please check if it work without ajax first.

    Regarding your last question: Though it is a general ASP.NET one, I can give you the answer to it, and it is no. The state of div set on the client would not be persisted after postback. You can use a hidden field in order to save the div state and then retrieve it accordingly on the server.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top