CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 2/25/2003 9:55:12 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 49 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
Akinc5000
Asp.Net User
Problem overriding TemplateSourceDirectory Property in a usercontrol2/25/2003 9:55:12 PM

0/0

So I have a custom usercontrol that serves as the template for a page, and all parsed content and dynamically added content is added to the usercontrol as a child control. The usercontrol must be in a subdirectory. Unfortunately, all webcontrols resolve urls from the template directory and so mylink.navigateurl = "default.aspx" would be rendered as "templates/default.aspx". Turns out that url is manipulated with ResolveUrl before beinng rendered. ResolveUrl cannot be overriden, but is based on the TemplateSourceProperty which CAN be overridden. So to work around this problem, I attempted to override the public property TemplateSourceDirectory as so:

Public Class PageTemplate
Inherits UserControl

Overrides ReadOnly Property TemplateSourceDirectory as String
Get
Return ""
End Get
End Property


End Class

I noticed some real funny behavior when I did this. I added the appropriate inherits attribute into the control directive for it to be loaded as the PageTemplate type.
Response.Write(Me.TemplateSourceDirectory) produced:
/templates

Response.Write(CType(Me, CrazyWeb.PageTemplate).TemplateSourceDirectory) produced:
/templates

However,
Response.Write(New CrazyWeb.PageTemplate().TemplateSourceDirectory) produced:
\
(which is correct)

Now I did some poking around with ildasm.exe in the system.web dll and while I'm really not very good at reading the native code, I think the problem stems from the loadcontrol method initializing it as a usercontrol, rather than its derived type. Does anyone know of any workarounds for this problem? I know I can't be the only person that doesn't want urls resolved relative to the template directory in their usercontrol.
vga
Asp.Net User
Re: Problem overriding TemplateSourceDirectory Property in a usercontrol2/26/2003 7:29:36 AM

0/0

Hi,

From what you're describing it sounds like you're doing about the same that the Master Pages technique does. Take a look at its source code and note how the Content class overrides TemplateSourceDirectory. Also note how in ContentContainer::OnInit method the TemplateSourceDirectory of each content is set to be the one from the Page instead of the usercontrol defining the template.
Victor Garcia Aprea
Microsoft MVP | ASP.NET

Looking for insights on ASP.NET?, read my blog: Followers of the IHttpHandler !!
mharoon
Asp.Net User
Re: Problem overriding TemplateSourceDirectory Property in a usercontrol9/8/2003 6:33:13 AM

0/0

Akinc5000,

Did you ever figure out a solution to your problem? I am in the same boat as you and have spent several hours trying to figuring out a solution! If you did, I would love to hear from you.

I have not checked out the master pasges sample mentioned above -- this is what I am going to do next.

Thanks.

3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Programming Data-driven Web Applications with ASP.NET Authors: Don Wolthuis, Donny Mack, Doug Seven, Pages: 704, Published: 2002
Programming Microsoft ASP.NET Authors: Dino Esposito, Pages: 1165, Published: 2003

Web:
Problem overriding TemplateSourceDirectory Property in a ... Problem overriding TemplateSourceDirectory Property in a usercontrol. Last post 09-08-2003 3:12 AM by mharoon. 2 replies. Sort Posts: ...
Problem overriding TemplateSourceDirectory Property in a ... Re: Problem overriding TemplateSourceDirectory Property in a usercontrol ... Re: Problem overriding TemplateSourceDirectory Property in a usercontrol ...
A Developer's Daily Life - The Blog of Patrik Dahlén protected override void AddParsedSubObject(object obj) { if (obj is Content) { .... Public Overrides ReadOnly Property TemplateSourceDirectory() As String ...
Jelle Druyts - Blog|Programming|.NET|Quirks TemplateSourceDirectory property is "the virtual directory of the page or user control that contains the server control". This means that a relative url is ...
ADS take control automaticaly - ng.asp-net-forum.windows ... system.string system.web.ui.icallbackeventhandler.raisecallbackevent · problem overriding templatesourcedirectory property in a usercontrol ...
Control.ResolveUrl Method (System.Web.UI) If the user control passes the relative path to the image (that is, ... This method uses the TemplateSourceDirectory property to resolve to the absolute URL ...
Control.ResolveUrl Method (System.Web.UI) Parameters. relativeUrl. The URL associated with the TemplateSourceDirectory property. ... The user control is located at /Store/UserControls/UC1.ascx. ...
DateTimePicker Class Members - Date Time Picker ASP.NET Web ... ResolveUrl (inherited from Control), Resolves a relative URL to an absolute URL based on the value passed to the TemplateSourceDirectory property. ...
Context Issues [Archive] - Spring Framework .NET Support Forums public override IHttpHandler GetHandler(HttpContext context, ...... In 1.1 the " TemplateSourceDirectory"-Property is overriden in the ...
Making sense of ASP.Net Paths - Rick Strahl's Web Log Because this uses the TemplateSourceDirectory property, it will also work with relative URLs in a user control that exists in a directory different from the ...




Search This Site:










simple user control question

control properties problem (urgent)

please, help to choose web hosting

checkboxs dinamics...

design time

examples of using controlbuilder

system explore control

ultima hosts problems

seperatortemplate

readonly property

csharp to vb.net conversion problem

explorer bar

retrieving click events from a compositional custom control

postback blues

feedback sought on ad upgrade methodology for large-ish domain

find all the controls placed according to the tabindex set at design time of the page.

server collection control

got hacked ???

composite control event problem

binding a composite control property to null data -- casting problem

web user control - persisting state accross postback

routing table quandry

postback data handler problem

hosting database folder - too many options?

how to implement skinning using a style path property?

property to run an exe

binding data to a custom control

custom control class name?

custom control using controlbuilder

can help me how to solve my a little complex control???

  Privacy | Contact Us
All Times Are GMT