Decrease Font Size
Increase Font Size
   BLOG

Working with Web Resources in ASP.NET 2.0

How to access embedded Resource in a .NET Assembly through WebResource.axd? How to access embedded Resource in C# from URL? Working with Web Resources in ASP.NET 2.0

Previous article: How to embed web resources

Images:

Image myImage = new Image();
ClientScriptManager cs = Page.ClientScript;
Type rsType = this.GetType();
myImage.ImageUrl = cs.GetWebResourceUrl(rsType, "MyTextScroller.images.nav-arrow-up.gif")

JavaScript:

Type rsType = this.GetType();
this.Page.ClientScript.RegisterClientScriptInclude(
                        rsType, "TextScroller_Script_Name",
                        Page.ClientScript.GetWebResourceUrl(rsType, " MyTextScroller.TextScroller.js"));

Style Sheet:

   
Type rsType = this.GetType();     
string csslink = @"<link rel='stylesheet' type='text/css' href='" + Page.ClientScript.GetWebResourceUrl(rsType, "MyTextScroller.TextScroller.css") + "' />";
LiteralControl include = new LiteralControl(csslink);
this.Page.Header.Controls.Add(include);

Comments (1) -

  • Mirco

    4/10/2010 8:40:23 PM |

    That's good!!! But i have a problem: the URL returned by the GetWebResourceUrl not work. Any Ideas??

Add comment

Loading