Reusing custom web control in the same web control

Hello,

I'm newbie in web development and of course asp.net. I am actually trying to build my first page and I'd like to know if it is possible to make a custom webcontrol that will contain itself. Let's say I want to draw a folder hierarchy in treeview-like structure. I thought I could make a control that will display a folder and if this folder contains subfolders then for each the control will include itself. Is this even possible? What would you suggest me to do to?
Thanks in advance.
Tom
Tom Hagen



http://thagen.dteam.info
0
TomHagen
8/19/2004 7:35:33 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

4 Replies
846 Views

Similar Articles

[PageSpeed] 6


If the control can have child controls, then I suppose it's possible. However, you might want to contain all the representative stuff in one instance, rather than recursively instantiating more and more of your control.

Peter Brunone
MS MVP, ASP.NET
Founder, EasyListBox.com
Do the impossible, and go home early.
0
peterbrunone
8/24/2004 1:23:26 AM
Thanks Peter for your reply.

My idea was to instantiate a component for root of the disk (ie: C:). The component should display the lable C: and should also list the folders on the disk and for each of the folders instantiate itself again. And as it is instantiated for each folder it reads subfolders of this folder and instantiate itself for each of them again. And again, and again...
This was my idea. But I came to problem: How to create an instance?
Let say that i have a Folder.ascx which is The Component. First line states something like <@ Control Language=VB ClassName="Folder" ...>. And in its code in For loop I need to do:
Dim SubFolder as New Folder
SubFolder.Name = "<The name of folder I found>"
Controls.Add(SubFolder)
But it does not know Folder type!
Do you have an experience/idea how to achieve this?
Thanks
Tom
Tom Hagen



http://thagen.dteam.info
0
TomHagen
8/24/2004 7:38:01 AM
Tom,

Strictly speaking, that would be a 'user control', not a 'custom control' (and yes, the nomenclature gets even more confusing).
Honestly, I'm not sure how you'd do this in a user control. I'd be interested to hear what the best-practices people say about recursively calling a control like this... I'd still recommend doing all the searching in one control, since I don't see anything to be gained by having one control instance per folder.
Peter Brunone
MS MVP, ASP.NET
Founder, EasyListBox.com
Do the impossible, and go home early.
0
peterbrunone
8/24/2004 5:06:59 PM
Yes, thanks for correcting me. As I wrote: I'm just starting with ASP and .NET. Until now I was Delphi programmer ... Still a lot confused with everything arround :)

The logic that I tried to draw comes just from my Delphi experience. To be honest I do not exactly need this logic, but for a DB application I'm trying to build, the tree-like loops seems to be the best. If anyone can show me any other way of solving it I would be very happy.
Tom Hagen



http://thagen.dteam.info
0
TomHagen
8/24/2004 6:08:27 PM
Reply:

Similar Artilces:

Web Custom Control within a Web Custom Control
I was wondering if this can be done and how. I've created a simple custom control that displays a header which is my first custom control. So I'm just a baby when it comes to this.. Within the header I currently have a property for breadcrumbs which is a string. What I would like to do is have the breadcrumb property  be a Link Button List. I did find a custom control of a Link Button List which is exactly what I wanted. My question is how can/do  I include this into my custom control? Can it done? How? Please help? I'm at a lose here.   Susan You should be able to do ...

Custom Web Control inside another Custom Web Control
Hi I created a custom web control (CusWebNew) that displays some textboxes by adding them to the ControlCollection of the webcontrol. I also created a custom webcontrol (CustWebButton) that inherts from Button control, and overrided the OnClick function. When I use CustWebButton on a regular web form, it seems to function correctly. However, when I added to be part of the ControlCollection of CustWebNew, it stops to work.   Any ideas why? Thanks Hey, What do you mean by stops to work?  Explain what you are trying to do with it and what it doesn't do.Brian"Trust in the...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

Server Web User Control or Web Custom Control
Ok, I made a DataGrid I like, stuck it in a Web Control Lib, and then to my toolbar. Now I want to take my nice little control and add it to a greater control, maybe place some buttons around it etc. I could always inherit from it in a new custom control and dynamically add the buttons, but I thought about using a Web User Control. I thought I could easily create a Web User Control, drop on my grid and the buttons on a form, and expose some properties and events, but once I got into it, I got a feeling that this isn't what a Web User Control is for. When designing a control li...

What is the difference between a Web User Control and a Web Custom Control
Hi ,please could you answer for the following question with example. i know wht they are. but i want to know hw they are existing in web pages with simple example. What is the difference between a Web User Control and a Web Custom Control?  Thanks in AdvanceDilip    Check this out .... hope these might help you out... http://support.microsoft.com/kb/893667http://msdn2.microsoft.com/en-us/library/aa651710(VS.71).aspx itsUrDAY  Hi, See the following URLs: https://msdn2.microsoft.com/en-us/library/fb3w5b53(VS.71).aspx(Introduction to Web User Contr...

Use Web Custom control or Web User control?
Friends,  I have a generic aspx page and its functions which is used in many .NET web application. The generic page contains a HTML Div control, server drop down list, server buttons, server textbox and it have different server and client functions to do its tasks for calling aspx pages in web applications. My problem is I do not know whether I should make that generic page as a web user control (but this is tedious because all other application folders must store frontpage aspx and code behind files of the generic page) or as a web custom control (This seems to be good beca...

custom web user control and web form
Guys,          I am trying to develop a context menu control for all of my pages. what i am trying to do is that i want the control to pick a datasource from the markup and then check whether its an xml file or a datatable. I created a class called datasource.   /**************************DataSource Class****************************/  public class DataSource { /// <summary> /// This is to identify unique elements from the markup /// </summary>protected string _ID; /// <summary> /// This will be the Datasource ID e...

web web web
Name: bahadir Email: sensiz_olmuyor_t1_at_hotmail.com Product: Firefox 2 Beta 2 Summary: web web web Comments: web sayfası yapmak Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

web controls and web user control
i have a problem in a web form , I have a webform that contains a web user control which in turn contains a html input form ,the web control events don't fire up ,When I click button ,no effect ,I don't know what is the effect of the html form which is in the web user control on the web controls in the web form ?? can any one help me the web control event should be handle in the code behind page, is the event handler for the button you are clicking registered? You can try double clicking the button, should give you the default btn_click event handler in code behind. Also, make ...

Use Web Control In a Web Control
Is this possible?I am working with an aspx page that consists of many different web controls.One of the web controls contains search criteria.  One of the criteria is a date range where I am trying to add a popup calendar --> which is another web controlCan I register the popupcaledar control on the questionaire control?  I have tried, but nothing seems to be registered.Any ideas will GREATLY help.Relax and have some Home Brew!Prosecute the Owner - Don't PERSECUTE the Breed!Breed Specific Legislation targets the WRONG end of the LEASH! Without seeing your code we can'...

controlling an object in a web control from the page the web control is placed in
I have created a web control in vb.net that has an image button and an image. when it loads the image button is visible and the image is not. I want to be able from the page which "includes" the web control to set the image button to invisible and the image to visible. When I tried this, the main page didn't recognise the image button or the image (both < asp: objects). help would be gratefully appreciated. oh yeah, it's inline code so any code behind stuff will just confuse me ;) Some code please.-- Justin Lovell...

I cannot drag web custom controls from toolbox to web form
I have created some web custom controls (both composite controls or derived/inherited controls).  I successfully added them to the toolbox. However, when I try to drag them onto the form, the cursor changes into a black circle with a diagonal line, and cannot drag them.  I also tried double-clicking them from the toolbox but it still won't work. I sent the Control Library (DLL) to a friend, and he managed to use it properly.  I am assuming this is a problem with my Visual Studio. Has anyone encountered such a problem?  Any suggestions or solutions?   Thanks. I...

what is the difference between web custom control,web user control,component class
please tell me in detail what is the web custom control,web user control,component class and what is the difference between web custom control, web user control,component class and when to use web custom control, when to use web user control, when to use component class Oh gosh. Such a nice question! I recommend you to start with this link from MSDN click here . I think you'll need a lot of coffe :) .George (.NET or .NOT) www.piasi.org...

Web resources about - Reusing custom web control in the same web control - asp.net.web-forms

Wikipedia:Reusing Wikipedia content - Wikipedia, the free encyclopedia
There are many reusers of Wikipedia's content, and more are welcome. If you want to use Wikipedia's text materials in your own books/articles/web ...

Andrea Reusing (@andreareusing) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

YouTube - Reusing Soda Can Tabs Closet Organizer Double Hanger
You are using an outdated browser, which YouTube no longer supports. Since some features on YouTube may not work, you are viewing a lightweight ...

The grey area of freelancers reusing their own work
Write more for less pay. In the content-hungry online media industry, there is a temptation for freelancers to reuse their own writing, research ...

Stop Reusing Your Old Exams, You LAZY Law School Professors!
How hard is it to write an exam for a course you've taught all semester? On a scale of one to ten ten involving programing a rocket ship, one ...

Daimler is reusing electric vehicle batteries to store renewable energy
A mock-up of the stationary storage unit that will use old electric car batteries in Germany. (credit: Daimler AG) When electric vehicle batteries ...

Rod Stewart Sued for Reusing Image of the Back of His Head
Celebrity photographer Bonnie Schiffman has filed a copyright lawsuit that claims

Ex-employee may have led to investigation into Colo. oral surgeon accused of reusing needles: Report
(CBS News) Colorado-based oral surgeon Dr. Stephen Stein's alleged reuse of needles and syringes at two of his dental practices may have been ...

Movie Studios Sued For Reusing Lesser Known Parts Of Famous Soundtracks
It’s going to be tough to prove. But if it goes through, this could lead to changes to the way that music is made – and used – in our movies ...

Renewable Storage — Company Reusing Old U-Haul Truck Bodies As Storage Units
... Renewable Storage repurposes old truck bodies as storage units, with reportedly all of the truck bodies that Renewable Storage — Company Reusing ...

Resources last updated: 12/24/2015 6:34:55 AM