This is a migrated thread and some comments may be shown as answers.

ClientID not being replaced

1 Answer 30 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Lenny_shp
Top achievements
Rank 2
Lenny_shp asked on 12 Jan 2010, 09:20 PM
                        <asp:RadioButtonList ID="rdoOffer" onclick="alert('<%= rdoOffer.ClientID %>');" 
                         runat="server"
                            <asp:ListItem Text="Yes" Value="Y"></asp:ListItem> 
                            <asp:ListItem Text="No" Value="N"></asp:ListItem> 
                        </asp:RadioButtonList>    

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.
2009.3.1210.35

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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Iana Tsolova
Telerik team
answered on 15 Jan 2010, 02:46 PM
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,
Iana
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.
Tags
Ajax
Asked by
Lenny_shp
Top achievements
Rank 2
Answers by
Iana Tsolova
Telerik team
Share this question
or