Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
User Controls
Message
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires Web
Titre:
Divers
Thread ID:
00759524
Message ID:
00759824
Vues:
20
Hi Bonnie,

If you don't want to hard-code the name of the ascx file and you don't want to use a table, how about using Reflection to get at the name of the class for your usercontrol? You will incur a performance hit but you could interogate the assembly to get the name of the class then use it to figure out the name of the ascx file.

>Dave,
>
>>>Data drive your page so the paths to your user controls will be stored in a table.
>
>Well, I'm not crazy about doing that either ... it doesn't really fit in with our paradigm. But, thanks for the idea, I'll keep it in mind as I look into other possibilities.
>
>Thanks,
>~~Bonnie
>
>
>
>>>Thanks, Dave. I discovered the LoadControl() method after I posted my original question. Is there *any* other way of doing this? I don't really like having to have the path and file name hardcoded like this.
>>
>>Data drive your page so the paths to your user controls will be stored in a table. In the IBuySpy sample the layout of the web site is stored in a SQL table. There is just one main aspx page that renders the whole site.
>>
>>>
>>>I've wondered if maybe I should be using Custom WebControls instead of UserControls, but from what I understand, there's no design surface for those. Is that correct? (I just started looking at that now).
>>>
>>
>>I haven't created my own custom controls in asp.net, so I don't know. With custom controls you have to create all your own HTML code that will render at runtime and do a lot of extra work to represent the control at design time.
>>
>>The bottom line with user controls versus custom controls is that user controls use containership and custom controls use inheritance. user controls are like include files in classic asp to group together several asp.net controls and reuse them on different webforms. You would use a custom control if you wanted to subclass the textbox control and make it behave differently like make it accept numbers only, for example.
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform