Link on an ImageUrl

5 posts, 1 answers
  1. Issac
    Issac avatar
    21 posts
    Member since:
    Mar 2012

    Posted 17 Apr 2012 Link to this post

    Is it possible to add a link to the image in the ImageURL of node?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Apr 2012 Link to this post

    Hi Issac,

    I suppose that you want to redirect to a URL while clicking on the image. I  can achieve this by adding a ImageButton to the NodeTemplate of the RadTreeNode and from the onclick event of that ImageButton I can redirect to the other page as follows.

    ASPX:
    <telerik:RadTreeView ID="RadTreeView1" runat="server">
        <Nodes>
                    <telerik:RadTreeNode runat="server" Text="a1" Value="A">
            <NodeTemplate>
                        <asp:ImageButton ID="lnk" runat="server" Text="lnk" onclick="lnk_Click" ImageUrl="~/Images/image.jpg" />
                    </NodeTemplate>
        </Nodes>
    </telerik:RadTreeView>

    C#:
    protected void lnk_Click(object sender, EventArgs e)
        {
            Response.Redirect("url");
        }

    Hope this helps.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Issac
    Issac avatar
    21 posts
    Member since:
    Mar 2012

    Posted 18 Apr 2012 Link to this post

    I am populating the TreeView from code.

    Dim lstSelected As RadTreeNode = New RadTreeNode(cCategory , "", myLink)
    lstSelected.ImageUrl = "images/btns/delbtn.gif"
    lstSelected.ToolTip = "Click to Remove Category" + cCategory  + " From Your Selection"
    lstYourSelection.Nodes.Add(lstSelected)

    There is no way to attached myLink to the image? javascript?
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Apr 2012 Link to this post

    Hi Issac,

    Try giving your link in the NodeClick event.

    ASPX:
    <telerik:RadTreeView ID="lstYourSelection" runat="server" OnNodeClick="lstYourSelection_NodeClick"></telerik:RadTreeView>

    C#:
    protected void lstYourSelection_NodeClick(object sender, RadTreeNodeEventArgs e)
        {
            
                Response.Redirect("url");
        }

    Thanks,
    Princy
  6. Issac
    Issac avatar
    21 posts
    Member since:
    Mar 2012

    Posted 19 Apr 2012 Link to this post

    Thank you Princy, that worked perfectly.


Back to Top
UI for ASP.NET Ajax is Ready for VS 2017