Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to embed resources in ASP.NET 2.0 assemblies
02-04-2011, 04:03 PM
Post: #1
How to embed resources in ASP.NET 2.0 assemblies
Embedding the resources in an assembly

Web Designers Directory | Advertise Web Design Business | Website Design
Find all posts by this user
Quote this message in a reply
08-12-2011, 08:38 PM
Post: #2
RE: How to embed resources in ASP.NET 2.0 assemblies
What are these resources?
These resources could be any resources that you need for proper display, functioning, validation, and execution of the components in your project. These are vital resources that tend to and need to stay consistent across the application.

Pakistan's Local Search Engine | Yellow Pages of Pakistan
Find all posts by this user
Quote this message in a reply
08-12-2011, 08:54 PM
Post: #3
RE: How to embed resources in ASP.NET 2.0 assemblies
Embedding the resources in an assembly
To do this, follow these steps:

1. Add the resource as an existing item into the project.
2. Set the resource type to be "embedded resource".

Hair Transplant
Find all posts by this user
Quote this message in a reply
10-10-2011, 01:51 PM
Post: #4
RE: How to embed resources in ASP.NET 2.0 assemblies
http://support.microsoft.com/kb/910445
Hope this help

Indochina Sails-Thailand tours-New York Accommodation
Find all posts by this user
Quote this message in a reply
01-23-2012, 02:45 AM
Post: #5
RE: How to embed resources in ASP.NET 2.0 assemblies
hat are the advantages of embedding them?
You could put all your dependencies into one single assembly and then ship the assembly out to whoever needs it without having to worry about stuff like does the user has the latest client-side scripts? Did the user remember to put the images in the /something/something/images folder? Did the user set the permissions for the new folder accordingly? Is there any conflict between the resources that my library requires and any other library? Well, the list could go on.
Back to the top
Embedding the resources in an assembly
To do this, follow these steps:

Add the resource as an existing item into the project.
Set the resource type to be "embedded resource".

Note This option is not available if you add the item directly to the Web site itself. Here is what you would see in such a situation:

Embedded resource


You can only apply this option on resources that are included with class libraries (assemblies in their own right). Here is what you would see:

Included with class libraries
Next, open the AssemblyInfo.cs file of that library, and then add the following line of code to it:

[assembly: WebResource("WebControlLibrary1.1.JPG", "img/jpeg")]

Add the following line of code and a reference to System.web.dll if missing:

using System.Web.UI

You need to use the namespace when you declare the resources as well as when you request the resources.
In the page (or in the control) that needs these resources, use the Page.ClientScript.GetWebResourceUrl method to get them.

For example, you might use the following methods:
To get an image that is used as an embedded resource, you use the following code example.

Image img = new Image();

img.ImageUrl = Page.ClientScript.GetWebResourceUrl(typeof(WebControlLibrary1.WebCustomControl1)​, @"WebControlLibrary1.1.JPG");


To add a style sheet to a page header, you use the following code example.

string includeTemplate ="<link rel='stylesheet' text='text/css' href='{0}' />";

string includeLocation = Page.ClientScript.GetWebResourceUrl(typeof(WebControlLibrary1.WebCustomControl1)​, "Assembly.styles.css");

LiteralControl include = new LiteralControl(String.Format(includeTemplate, includeLocation)); HtmlControls.HtmlHead) Page.Header).Controls.Add(include);

Hair Transplant Pakistan
Find all posts by this user
Quote this message in a reply
02-21-2012, 01:54 AM
Post: #6
RE: How to embed resources in ASP.NET 2.0 assemblies
These resources could be any resources that you need for proper display, functioning, validation, and execution of the components in your project. These are vital resources that tend to and need to stay consistent across the application.

Electrical services Perth | Electrical contractors perth | Electrician Perth
Find all posts by this user
Quote this message in a reply
08-31-2012, 12:05 AM
Post: #7
RE: How to embed resources in ASP.NET 2.0 assemblies
this is very informative post thanks for sharing

Corporate Photography Melbourne| Commercial Photography Melbourne| Headshot Photography Melbourne|
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)