Web resources in .Net 2.0, allow control developers to package up client files such as scripts, images, style sheets etc. and use them in the generated rendering simply by embedding them into the assembly, rather than having to scatter them into the file system.
These are the steps to be followed to generate the WebResource Assembly.

1. create a folder say MyResource in VS.Net 2005 the project
2. Put the recources like .js, .css .gif etc in the folder.
3. Select All Resources and set the Property Build Action to "Embedded Resource"
4. Put the following attributes in Assemblyinfo.cs:-

 [assembly: System.Web.UI.WebResource("myCss.css", "text/css")]
 [assembly: System.Web.UI.WebResource("myScript.js", "text/javascript", PerformSubstitution = true)]
 [assembly: System.Web.UI.WebResource("MyImage.gif", "image/gif")]

5. Compile the project.

Now this assembly will be the Web Resource assembly, It will contain all the compiled resources.

We can access these resources by refering the above assembly:-

.js:    Page.ClientScript.GetWebResourceUrl(this.GetType(), "myScript.js"));
.css:  Page.ClientScript.GetWebResourceUrl(this.GetType(), "myCss.css")
.gif:   Page.ClientScript.GetWebResourceUrl(this.GetType(), "myImage.js"));

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:14 PM | Cote

# re: Webresource ASP.Net

Poor article. Very simple!!!!! 2/28/2007 7:15 PM | Hyoga

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:16 PM | Cote

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:16 PM | Cote

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:16 PM | Cote

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:16 PM | Cote

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:16 PM | Cote

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:17 PM | Cote

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:17 PM | Cote

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:17 PM | Cote

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:17 PM | Cote

# re: Webresource ASP.Net

You stupid! 2/28/2007 7:36 PM | João

# re: Webresource ASP.Net

I like to eat my boogers. 3/31/2008 2:09 AM | HairyBoogers

Post a comment





 

 

News

Employers
Soppa Group India
iSmart Panache Inc
R Systems Internationals Ltd
Technovate eSolutions Pvt Ltd
The contents of this blog are my personal opinion and do not represent in any way the view of my employer.
These postings are provided "AS IS" with no warranties, and confer no rights.

Google PR™ - Post your Page Rank with MyGooglePageRank.com

Archives

Post Categories

Image Galleries

Articles & Magazines

ASP.Net 2.0 Compilation

ASP.Net, Blogs I refer...

Atlas

Dost

Drivers and Software Download

Garhwal

Travel Domain

WSS and WebParts

Syndication: