Absolute Path to be rendered by a control


    Actually i am creating one user control(ASCX) by droping a grid in it. Now i am generating the html of this user control as follows:

Page page = new Page();



Control control = page.LoadControl(@"~/testGridUC.ascx");

HtmlForm htmlForm = new HtmlForm();HtmlGenericControl htmlGenericControl = new HtmlGenericControl("DynamicUserControl");





StringWriter writer = new System.IO.StringWriter();HttpContext.Current.Server.Execute(page, writer, true);

output = writer.ToString();



catch (Exception ex)


throw ex;


return output;


         Everything above is going fine except the HTML generated for the user control contains Relative Path rather than Absolute Path. for e.g.:

 <script id="dxis_1523228171" src="/GridViewDrillDownJQueryAjax/WebResource.axd?d=vqlDqaaIZtadaaunkWx54r6zWhBjsjhBO6BX_QtHPd2xaA9bug0DvRPbuv8d8OvRpwkwEtNhSotpUwcfw2dm2b90H42oDRPdDQSjpXmkTTI1&amp;t=633654491430963222" type="text/javascript"></script>

  What i want it tobe something like this:

 <script id="dxis_1523228171" src="http://localhost:2512/GridViewDrillDownJQueryAjax/WebResource.axd?d=vqlDqaaIZtadaaunkWx54r6zWhBjsjhBO6BX_QtHPd2xaA9bug0DvRPbuv8d8OvRpwkwEtNhSotpUwcfw2dm2b90H42oDRPdDQSjpXmkTTI1&amp;t=633654491430963222" type="text/javascript"></script>

  so that it gets the resources from the absolute path rather than looking the resources locally.

Any help will be highly appreaciated.


Burhan Ghee

4/29/2009 4:17:36 PM
asp.net.custom-server-controls 3498 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 6


 <script id="dxis_1523228171" src="/GridViewDrillDownJQueryAjax/WebResource.axd?d=vqlDqaaIZtadaaunkWx54r6zWhBjsjhBO6BX_QtHPd2xaA9bug0DvRPbuv8d8OvRpwkwEtNhSotpUwcfw2dm2b90H42oDRPdDQSjpXmkTTI1&amp;t=633654491430963222" type="text/javascript"></script>

Where's the code rendering this tag? Is it in your user control? Could you provide the code? If it's rendered by built-in controls that is used in your user control it's difficult to change it. An option is to override the Page, like below:

public class MyPage : Page {protected override void Render(HtmlTextWriter writer)


StringWriter sw = new StringWriter();

HtmlTextWriter htw = new HtmlTextWriter(sw);


string s = sw.ToString();writer.Write(s.Replace("WebResource.axd", http://localhost:1234/Secure/WebResource.axd));



Then use MyPage instead of Page in your code.

Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
5/4/2009 6:00:37 AM

Similar Artilces:

how to have both server controls and html controls rendered in a custom control?
I have a custom control in which there is an html text box.when you click on it , a div containing a table is appeared and according to what you select in that table a text is set to the text box. It works fine but the problem is: as the text box is an html element it doesn't have viewstate and when a post back occures in the page its value disappeares.I tried a hidden field to keep its value.again there is another problem : I put this custom control in a usercontrol and put the usercontrol in a multiview and by clicking on a button this view is selected and by clicking another bu...

Using a server control in the rendering a custom control
Hi. I have a custom control that overrides the Render method to draw itself.  Is it possible to use a server control (asp:Image, wwHoverPanel, etc.) inside such a custom control or would I have to rewrite my custom control as a composite control? I'd like to do something something like:protected override void Render(HtmlTextWriter w) { w.RenderBeginTag(HtmlTextWriterTag.Table); w.RenderBeginTag(HtmlTextWriterTag.Tr) w.RenderBeginTag(HtmlTextWriterTag.Td) // somehow place asp:Label here w.RenderEndTag(); // column w.RenderEndTag(); // row ...

Custom Server Control to render multiple Controls
I have a need to build a reusable "Custom Server Control" that will in turn render multiple controls at runtime. The four controls I need it to render are as follows  <asp:Label ID="divLogin" runat="server" Text=" | " /> <asp:LoginStatus CssClass="footer" ID="LoginStatus1" runat="server" LogoutPageUrl="Default.aspx" /> <asp:Label ID="divAdmin" runat="server" Text=" | " /> <asp:HyperLink CssClass="footer" ID="btnAdmin" NavigateUrl=&...

How to render a repeater control in the custom server control?
 How to render a repeater control in the custom server  control because there is a lot of element inside the repeater control? My code is as follows: <div> <asp:Repeater ID="rptFields" runat="server"> <HeaderTemplate> <table> </HeaderTemplate> <ItemTemplate> <tr> <td><%# Eval("Prompt") %>:</td> <td><asp:PlaceHolder ID="plControl" runat="server" /> <input type="...

Usercontrol vs Custom Server Controls, Any need for Custom Server Controls
Hello I'm new to ASP.Net so this is probably a stupid question but, is there any need to create customer server controls now that you can pre-compile usercontrols into a dll and thus easily share between applications? This blog post from David Ebb describes how to do it and the restrictions he note don't seem that bad (other than being able to embed resources such as images in the dll). http://blogs.msdn.com/davidebb/archive/2005/10/30/487160.aspx His article desribes the techniques for ASP.Net 2.0 and he suggests that there will be further improvements in .Net 3.5 in this ar...

How to Render controls within an UpdatePanel in a Custom Server Control
Hi,Im writting a CompositeControl that contains a few UpdatePanels (TabContainer with an UpdatePanel on each TabPanel to make Tab control panels load "on-demand"). I want to control the renderring of the controls within the UpdatePanel's ContentTemplateContainer.How should I implement the render method of my CompositeControl?Should I use a custom UpdatePanel (inherit from UpdatePanel and override the RenderContents method)? is there a simpler solution? (because I need a different "render" for each tab panel....)Thanks Tal88 Hi, I want to control the renderring o...

Custom Server Control Vs Web Parts, Any need for Custom Server Control
Hello I've just posted a similar question on why you need server controls when you can pre-compile usercontrols and redistribute them. http://forums.asp.net/p/1397433/3010100.aspx#3010100 I've seen lots of (usercontrol vs web part) but not much on web part vs custom server control. According to the MSDN site you can put web parts onto a normal asp.net page outside of a web part zone and they behave just like custom server controls. So, if you are creating a bunch of controls for redistribution to customer asp.net sites and/or SharePoint sites why don't you just create Web Par...

problems listenening to events on a custom server control from another custom server control
 Hi all,I am having problems listening to events on one of custom server controls(AddBookmark) from another custom server control(BookmarkList). The listener or the BookmarkList control has a property that can be set to the AddBookmark control (string at design but the reference is obtained at run-time). I am able to get a reference to the AddBookmark control and add a listener to it on the BookmarkList control on the OnPrender of BookmarkList. But the problem is that when the events on AddBookmark gets fired, the listener added from the BookmarkList is no longer present and the listene...

Custom Server Control Made of Custom Controls?
I'm giving myself a crash course in custom server controls, and I have a quick general question. Can I have a custom server control that is composed of other server controls I created. I'm pretty sure the answer is yes, but I want to be positive. Yes http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondevelopingcompositecontrols.asp Shows how to combine existing controls into a new control using class composition. -ron Thanks! ASP.NET so rocks! Making page components extensible objects is such a great idea! I love it....

Render a server control is faster than render a user control?
Render a server control is faster than render a user control? If there is many server side controls.   Thank you very much.As Heinlein said "specialization is for insects" explore beyond the universe. Usually the decision on what to use Custom Server Controls or User Controls goes back to your need and to the usage of the control itself. So if a control might be used in several projects, then go for a Custom Server Control, else go for a User Control which is easier to develop for sure. After all, both are control containers, which include child controls, and any page...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

Custom Server Control With Child Control
All, I am currently putting together a very simple control. The new control outputs a table with two rows. The top row contains a heading and the bottom row will contain any other content. The control as it stands works perfectly well and I can place text into the content row no problem. Now, to the problem. Once I'd completed the control I figured it would be neat to enable the developer to add controls directly into the bottom row (content row) of the outputted table. As you probably know the WebControl class has a Controls collection which the developer can use to add any other...

Custom Server Control with Child Controls
I have a custom server control <xx.Parent... /> which parses custom child controls <xx.Child... />. In Visual Studio 2008, IntelliSense shows me both when I start typing my control namespace. How can I prevent the child control from showing up in IntelliSense  unless I'm adding it within the parent tags?Thanks. --Rudy...

Creating .Net custom server controls and .Net pages programatically
Thanks a lot for reading this and greatly appreciate your inputs I am writing a webinterface that lets users configure options that'll create an interface for them and generete the webpage. So I am having to programattically create custom server controls and .Net page with code behind to support the functionality. Are there APIs in the .NET SDK that let you do this. Any pointers would be greatly helpful Thanks a lot Sathya Controls on the fly? Or Create code on the fly? I think it is the latter so here we go - look at the following namespaces: * System.Reflection.Emit - gen...

handling events for controls in custom server control
Hi,     I am having a problem in using server controls in ASP.Net, with C#.  I am trying to create a server control which contains 2 other server controls that I created (Called MyImageButton).  MyImageButton extends the standard ImageButton with some other properties & methods that I needed.  It therefore also has the 'OnClick' event.  From the original server control, I would like to handle the Click event for these 2 image buttons in the same server control.  Basically, this server control will show 2 images, ascending and descendin...

Web resources about - Absolute Path to be rendered by a control - asp.net.custom-server-controls

Absolute - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Absolute Radio (@absoluteradio) 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 ...

Absolute Abs on the App Store on iTunes
Get Absolute Abs on the App Store. See screenshots and ratings, and read customer reviews.

Danny Green calls Rumblr fight app an 'absolute disgrace'
In 1999, the first rule was to not talk about it. In 2015, you can sign up for it through LinkedIn.

Myanmar election: Aung San Suu Kyi's NLD party takes absolute majority in parliament
Aung San Suu Kyi claims an historic victory in Myanmar, with her NLD party securing a majority to govern.

Donald Trump: Most of The Media Are ‘Absolute Scum’
In a rousing campaign speech in Mt. Pleasant, SC tonight, GOP front-runner Donald Trump explained his call to prevent muslims from entering the ...

Open Thread: 80s Nostalgia Is the Absolute Worst
Pataki just said he would restart the Star Wars missile defense program to defend against radical Islam. #RJCForum — Josh Rogin (@joshrogin) ...

The absolute worst ads of 2015
It's actually been a reasonably decent year for ads, as there hasn't been anything as godawful as 2013's creepy Galaxy Gear ad or Sprint's tragicomic ...

Putin Praises `Absolute Leader' Trump as Colorful, Talented Guy
President Vladimir Putin hailed Donald Trump as the “absolute leader” in the U.S. presidential contest, praising the candidate’s talk about building ...

Mike Huckabee: Build a Coalition to ‘Bomb the Absolute Stink’ out of ISIS, Follow With Troops
GOP presidential candidate former Arkansas Gov. Mike Huckabee is blasting President Obama and explaining if elected he would combat ISIS.

Resources last updated: 12/18/2015 6:20:28 PM