OnClientClick radopen

2 posts, 0 answers
  1. Kjell
    Kjell avatar
    195 posts
    Member since:
    May 2011

    Posted 08 Sep 2013 Link to this post

    I have a ASP:DataList with asp:Linkbutton in a ItemTemplate that i try to open a telerik:RadWindow.
    I want to send a id with the url using OnClientClick="radopen

    This work fine for me, i can pick upp the id 3:
    <asp:Linkbutton ID="lbVisa" OnClientClick="radopen('visa.aspx?id='+'3','RadWindow1');return false;" Text="Läs mer..." runat="server" />

    But i want to bind the id with the Container.DataItem in the OnClientClick="radopen, but get "The server tag is not well formed.".
    <asp:Linkbutton ID="lbVisa" OnClientClick="radopen('visa.aspx?id='+'<%# DataBinder.Eval(Container.DataItem, "id") %>','RadWindow1');return false;" Text="Läs mer..." runat="server" />
    What do i wrong?
    Please excuse my bad english ....

  2. Marin Bratanov
    Marin Bratanov avatar
    3564 posts

    Posted 09 Sep 2013 Link to this post

    Hi Kjell,

    You would get this error with or without any of our controls. It stems from the fact that the quotation marks around the property value of the control conflict with the quotation marks in the databound expression. You would need to either find a way to remove the quotation marks, or set the values from the code-behind, much like it it done in this online demo: http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window. Note that the databound expression is not evaluated at all in the attribute property. You can examine the rendered HTML of the page and you will see something like this:
    <a id="RadGrid1_ctl00_ctl10_lbVisa" onclick="radopen("visa.aspx?id="+"<%# DataBinder.Eval(Container.DataItem, "id") %>","RadWindow1");return false;" href="javascript:__doPostBack('RadGrid1$ctl00$ctl10$lbVisa','')">

    Marin Bratanov
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top