Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
User Controls
Message
General information
Forum:
ASP.NET
Category:
Web forms
Title:
Miscellaneous
Thread ID:
00759524
Message ID:
00759917
Views:
25
I would recommend putting the path and name in the LoadControl method and go from there. If you added the Usercontrol at design time, VS would be doing the same thing at the top of the aspx file.

>>Is your user controls in a different directory then where your web site is?
>
>No, but the website is not all one big directory, there are sub-directories. But, as far as a path goes, it seems I can use a virtual path, as Dave pointed out to me in another post, ("~/SubDir/MyControl.ascx"). I guess I'm resigned to the fact that I have to do this, I'm just not crazy about it. It seems so un-OOP-like. <g> But then, WebForms are a lot different than WinForms ... I'm still trying to get used to the paradigm shift.
>
>
>
>>
>>>Hi Cathi,
>>>
>>>Any idea how bad of a performance hit that might be? Only problem is (and I haven't tried it yet), I'm guessing that Reflection won't get me the path too, will it? If I have to hard-code a virtual path, then I guess I have to.
>>>
>>>I guess now I'm just wondering if there is any other way of doing this other than using the LoadControl() method.
>>>
>>>~~Bonnie
>>>
>>>
>>>>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.
>>>>
-----------------------------------------

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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform