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

Cancel OnClientNodeClicked for LinkButton control within a NodeTemplate

1 Answer 31 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Michael Hunt
Top achievements
Rank 1
Michael Hunt asked on 09 Sep 2011, 02:12 PM
Hi,

- I am using version 2011.1.519.35 of your ASP.NET for AJAX controls.
- I am using the Treeview with a NodeTemplate.
- In the NodeTemplate I am displaying two things:

  1. Text in an ASP Label
  2. A LinkButton that allows users to navigate to other pages in the web app.  Note that my LinkButton has NO Text Property.

I also use the OnClientNodeClicked event.  When a user clicks on the node, the javascript function executes a RadAjaxManager.ajaxRequest to load other information on the page.

I do want to run the OnClientNodeClicked javascript function when the user clicks on the Node's Text and that works.

I do NOT want to run the OnClientNodeClicked javascript function when the user clicks on the LinkButton in my NodeTemplate.

IMPORTANT:  When my LinkButton has a value set in it's Text Property, I can click on the text of the LinkButton and it does NOT run the OnClientNodeClicked

MY PROBLEM:
But when my LinkButton as NO Text property (I want to only display an image, no text) and when I click on the Image for the LinkButton, the OnClientNodeClicked function is running.

Since my LinkButton's purpose is simply to navigate the user to another page in my web app, I want to NOT run OnClientNodeClicked when they click the image because as I mentioned, it does an ajaxRequest to that same page and updates another user control there.  That is a postback I don't want since I just want to navigate to another page.

Instead of a LinkButton, I've also tried using an asp:Hyperlink control and an asp:Literal with an <a href...> that I build in server-side code.

QUESTION:
So how I can either determine that the Image in the LinkButton was clicked in the OnClientNodeClicked function and then cancel / exit that client event, or how can I set up my NodeTemplate so that the Image in the LinkButton does not fire the OnClientNodeClicked function in the first place?

My treeview is as simple as this:

 

 

<telerik:RadTreeView ID="SavedReportsTreeView" runat="server" Width="100%" Height="500px" SkinID="cbsTreeView"
   OnClientNodeClicked="ClientNodeClicked"
   OnClientNodeExpanding="ModifyCookieOnExpand"
   OnClientNodeCollapsing="ModifyCookieOnCollapse" >
     <NodeTemplate
          <asp:Label ID="Label1" isText="true" runat="server" Text='<%# DataBinder.Eval(Container, "Text") %>' /> 
          <asp:LinkButton ID="runReportLinkButton" runat="server" Text="" >
               <asp:Image ID="runReportInfoImage" style="padding-left: 5px;" runat="server" ImageUrl="~/img/icons/report_go.png" />
          </asp:LinkButton>
     </NodeTemplate>
</telerik:RadTreeView>

  

Thanks,
Michael

1 Answer, 1 is accepted

Sort by
0
Michael Hunt
Top achievements
Rank 1
answered on 09 Sep 2011, 02:50 PM
UPDATE:
I've figured it out.  If I use an asp:ImageButton in the nodetemplate, it does NOT fire the OnClientNodeClicked method...
Tags
TreeView
Asked by
Michael Hunt
Top achievements
Rank 1
Answers by
Michael Hunt
Top achievements
Rank 1
Share this question
or