CodeVerge.Net Beta
Login Idy
Register Password
  Forgot?
Explore    Item Entry    Profile   
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > newsgroup > asp.net forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 3/11/2007 11:49:27 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 11 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
monirkuet24
Asp.Net User
TreeView3/11/2007 11:49:27 AM

0/0

Hi,

how can I add control such as Button to TreeView.

 

Actually I have tried this through

TreeView.Controls.Add( Control child) method but it gives exception that TreeView  does not allow child control.

 

 

Zhao Ji Ma - MS
Asp.Net User
Re: TreeView3/14/2007 10:38:03 AM

0/0

Hi,

The default TreeView control in ASP.NET can only render text, icons and checkboxes.

 


Zhao Ji Ma
Sincerely,
Microsoft Online Community Support

?Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ?
TheCheeta
Asp.Net User
Re: TreeView3/15/2007 3:16:57 AM

0/0

Is there absolutely no way to have a treeview contain radio buttons? For instance, I am trying to do something like this:

 

  • Option 1
  • Option 2
  • Option 3

           [ ] Sub Option 1
           [ ] Sub Option 2
           [ ] Sub Option 3

 
I would like to make it such that the Sub Options behave like Children in a treeview, where they only show up once the Option 3 is selected. Otherwise, Options 1, 2 and 3 act like radio buttons, being mutually exclusive.
 

Zhao Ji Ma - MS
Asp.Net User
Re: TreeView3/19/2007 5:55:54 AM

0/0

Hi,

You can do it, however I think you need custom it yourself, either writing a custom TreeView control or rendering it yourself. But I think it might be quite complex according to your requirement.


Zhao Ji Ma
Sincerely,
Microsoft Online Community Support

?Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ?
mriesterer
Asp.Net User
Re: TreeView4/19/2007 3:48:00 PM

0/0

 Rather then creating a Button I'd like to have an ImageButton. But TreeNode does not inherit from WebControl, so I don't know how to retrieve the ImageUrl from an image located in the dll as resource.

Something like

 

button.ImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof(WebCustomControl1), "MyCompany.Web.Resources.edit.gif"); 
 

is not possible. Any suggestions? thx a lot

 

With the solution below you got to use CommandTreeView instead of TreeView as the control on the page. 

 

 public class CommandTreeView : TreeView
{
protected override TreeNode CreateNode()
{
//return base.CreateNode(); return new CommandTreeNode();
}
}
  
namespace MyCompany.Web.UI
{
[Flags]
public enum CommandButtonSet
{
None = 0,

Edit = 1,

Delete = 2,

MoveUp = 4,

MoveDown = 8
}

public class CommandTreeNode : TreeNode
{

private CommandButtonSet _commandButtonSet = CommandButtonSet.None;

private List _buttons = new List();

public CommandTreeNode()
{

}

public CommandTreeNode(String text, String value)
: base(text, value)
{

}

public CommandButtonSet CommandButtonSet
{
get { return _commandButtonSet; }
set { _commandButtonSet = value; }
}

protected override void RenderPreText(System.Web.UI.HtmlTextWriter writer)
{
base.RenderPreText(writer);

if ( (CommandButtonSet & CommandButtonSet.Edit) == CommandButtonSet.Edit )
_buttons.Add(GetButton("edit", Value, "edit.gif", "Edit"));

if ( (CommandButtonSet & CommandButtonSet.Delete) == CommandButtonSet.Delete )
_buttons.Add(GetButton("delete", Value, "delete.gif", "Delete"));

if ( (CommandButtonSet & CommandButtonSet.MoveDown) == CommandButtonSet.MoveDown )
_buttons.Add(GetButton("moveUp", Value, "moveUp.gif", "Move Up"));

if ( (CommandButtonSet & CommandButtonSet.MoveUp) == CommandButtonSet.MoveUp )
_buttons.Add(GetButton("moveDown", Value, "moveDown.gif", "Move Down"));

foreach ( WebControl control in _buttons )
{
control.RenderControl(writer);
writer.Write("&nbsp;");
}

}

private WebControl GetButton(string commandName, string commandArgument, string img, string alternateText)
{
Button button = new Button();
button.CommandName = commandName;
button.CommandArgument = commandArgument;
button.Text = alternateText;
return button;
}

protected override object SaveViewState()
{
Object[] state = new Object[2];
state[0] = base.SaveViewState();
state[1] = CommandButtonSet;
return state;
}

protected override void LoadViewState(object state)
{
if ( state != null )
{
Object[] savedState = (Object[])state;
CommandButtonSet = (CommandButtonSet)savedState[1];
base.LoadViewState(savedState[0]);
}
}
}
}
 
5 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

Treeview expanded state - microsoft_downloads ... Treeview expanded state, > ROOT > NEWSGROUP > Asp.Net Forum > ... The normal Treeview got an hiddenfield ... I customized some of the treeview adapter. ...
Yahoo! UI Library: TreeView Using TreeView. Known Issues. YUI on Mobile Devices. Support & Community ... Examples: Explore examples of the TreeView Control in action. ...
TreeView Simple program for displaying phylogenies. ... TreeView provides a simple way to view the contents of a NEXUS, PHYLIP, Hennig86, ... TreeView manual and FAQ ...
TreeView: JavaScript DHTML Tree Menu GubuSoft TreeView Favorites Manager Web File Browser About ... "I tested a number of TreeView components and yours was the only one with acceptable performance. ...
ASP.NET QuickStart Tutorials The TreeView supports both postback-style events and simple hyperlink navigation, ... The visual elements of a TreeView are labelled in the figure below. ...
TreeView manual Simply place the TREEVIEW application in the desired folder. To access online help from within TREEVIEW you will need the free Internet ...


 
All Times Are GMT