Geeks With Blogs

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

Narendra Tiwari

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"));

Posted on Monday, March 27, 2006 2:26 PM .Net | Back to top


Comments on this post: Webresource ASP.Net

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by Cote on Feb 28, 2007 7:14 PM

# re: Webresource ASP.Net
Requesting Gravatar...
Poor article. Very simple!!!!!
Left by Hyoga on Feb 28, 2007 7:15 PM

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by Cote on Feb 28, 2007 7:16 PM

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by Cote on Feb 28, 2007 7:16 PM

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by Cote on Feb 28, 2007 7:16 PM

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by Cote on Feb 28, 2007 7:16 PM

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by Cote on Feb 28, 2007 7:16 PM

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by Cote on Feb 28, 2007 7:17 PM

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by Cote on Feb 28, 2007 7:17 PM

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by Cote on Feb 28, 2007 7:17 PM

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by Cote on Feb 28, 2007 7:17 PM

# re: Webresource ASP.Net
Requesting Gravatar...
You stupid!
Left by João on Feb 28, 2007 7:36 PM

# re: Webresource ASP.Net
Requesting Gravatar...
I like to eat my boogers.
Left by HairyBoogers on Mar 31, 2008 2:09 AM

Your comment:
 (will show your gravatar)


Copyright © Narendra Tiwari | Powered by: GeeksWithBlogs.net