Home All Groups Group Topic Archive Search About
Author
30 Dec 2005 9:26 PM
SunSmile
Hi,
Iam a using a custom treeview control, taking an example from
http://fredrik.nsquared2.com/viewpost.aspx?PostID=299.

I have created two hyperlink's after each node in the treeview. When i click
on any one of the hyperlink's the selectednodechanged event of the custom
treeview control is not firing up.

My sample treenode is as below.

<<Some Text>> hyperlink1 hyperlink2

I am creating hyperlink1 and hyperlink2 as follows 

protected override void RenderPostText(HtmlTextWriter writer)
{

            writer.Write("      ");
            writer.WriteBeginTag("A");
            writer.WriteAttribute("href", "Treeview.aspx"  );

            writer.Write(">");
            writer.Write("Reply");
            writer.WriteEndTag("A");

            writer.Write(" ");
            writer.Write(" ");
            writer.Write(" ");

            writer.WriteBeginTag("A");
            writer.WriteAttribute("href", "Treeview.aspx");
            writer.Write(">");
            writer.Write("Edit");
            writer.WriteEndTag("A");
  }

Any furthur comments and suggestions are welcome.
Thanks in advance.

Author
1 Jan 2006 1:27 AM
Keith Patrick
For ease of coding, I'd recommend this instead:
HyperLink link = new HyperLink();
link.NavigateUrl = "TreeView.aspx";
link.Text = "Edit";
link.RenderControl(writer);

Are your treenodes showing URLs or are they javascript method calls?  If
they are the former, then your tree is in navigate mode, and thus the
selection events won't fire.  You can change the mode by altering the
binding for that particular node depth (via the DataBindings child element
for the TreeView)
Author
1 Jan 2006 6:36 PM
SunSmile
Thanks Patrick,
       Can you tell me in more detail how to change the navigate mode. Also
how do i remove the hyperlinks for the Nodes (Not the two hyperlinks i have
added)and make them as simple text. Is it possible to do so?

Thanks,
SunSMile



Show quoteHide quote
"Keith Patrick" wrote:

> For ease of coding, I'd recommend this instead:
> HyperLink link = new HyperLink();
> link.NavigateUrl = "TreeView.aspx";
> link.Text = "Edit";
> link.RenderControl(writer);
>
> Are your treenodes showing URLs or are they javascript method calls?  If
> they are the former, then your tree is in navigate mode, and thus the
> selection events won't fire.  You can change the mode by altering the
> binding for that particular node depth (via the DataBindings child element
> for the TreeView)
>
>
>
Author
2 Jan 2006 3:51 AM
Keith Patrick
Yeah, basically it's a matter of the databinding.  This is an example of a
databinding that sets the 3rd nest level of a tree I have bound to a
SiteMapDataSource (hence the field names of "url" and "title") to selection
mode (as you can see by the URL, which is a call do doPostback):
                                  <DataBindings>
                                    <asp:TreeNodeBinding Depth="2"
                                                         NavigateUrlField=""
                                                         DataMember=""
                                                         TextField="Title"
                                                         ValueField="url" />
                                  </DataBindings>

The key to taking out the URLs lies with setting the data and navigateURL
members to String.Empty.  The ValueField determines what the CommandArgument
is going to be (and is passed in as a param to doPostback)
Author
4 Jan 2006 5:09 PM
SunSmile
Thanks patrick,
           That did the trick.

Show quoteHide quote
"Keith Patrick" wrote:

> Yeah, basically it's a matter of the databinding.  This is an example of a
> databinding that sets the 3rd nest level of a tree I have bound to a
> SiteMapDataSource (hence the field names of "url" and "title") to selection
> mode (as you can see by the URL, which is a call do doPostback):
>                                   <DataBindings>
>                                     <asp:TreeNodeBinding Depth="2"
>                                                          NavigateUrlField=""
>                                                          DataMember=""
>                                                          TextField="Title"
>                                                          ValueField="url" />
>                                   </DataBindings>
>
> The key to taking out the URLs lies with setting the data and navigateURL
> members to String.Empty.  The ValueField determines what the CommandArgument
> is going to be (and is passed in as a param to doPostback)
>
>
>