Right now. There are many developers who are already using Asp.net2.0 's webresource functionality. WebResource allows us to embed resources into the assembly. including images, text, and so on.
In introducing WebResource, we have to introduce WebResource.axd, let's take a look
Script language= "javascript" src= "webresource.axd?a=s&r=webuivalidation.js&t=631944362841472848" type= "TE" Xt/javascript "></script> At present I find that the parameters of WebResource.axd are different from the current version. Introduced properties in earlier articles:
A assembly name
R Resource File name
Time of last modification of the T assembly
WebResource.axd is just a map in the ISAPI. You can also use the IHttpHandler. <add verb= "Get" path= "WebResource.axd" type= "System.Web.Handlers.AssemblyResourceLoader"/> WebResource.axd is the process of processing an HTTP request through a Assemblyresourceloader class, identifying which resource is being fetched from which assembly, based on the program passed in query.
The following is an example of a micro-control piece.
Use steps:
to add a resource (such as an image) to be embedded in an item
in Explorer, click a file, Build action in the property window to select Embedded Resource (embedded Resource).
Add the following file to your Assessbly.cs file
[Assembly:webresource ("Obies.Web.UI.WebControls.NumericTextBox.js", " Application/x-javascript ")]
[Assembly:webresource (" Obies.Web.UI.WebControls.NumericTextBox_Silver_BtnUp.gif "," Image/gif ")] Note the webresourceattribute format:
[Assembly:webresourceattribute (" MyNameSpaces.Resources.MyImage.gif "," Image/gif ")]
in control source. You need to use the following code to obtain the image
//Get WebResource URL for the embedded GIF images
& nbsp; String btnupimgsrc = this. Page.ClientScript.GetWebResourceUrl (typeof (NumericTextBox),
"Obies.Web.UI.WebControls.NumericTextBox_ "+ this. Imageset.tostring () + "_btnup.gif"); GetWebResourceUrl method:gets a URL reference to a server-side resource. (Gets a URL reference to the server-side resource)
I found it in earlier versions. It uses the following method: This.page.GetWebResourceUrl
The code above is to get the image name from the specified assembly: Obies.Web.UI.WebControls.NumericTextBox_ "+ this. Imageset.tostring () + "_btnup.gif, which returns the URL reference address of a server-side resource. Similar to:
webresource.axd?d=gwyjblnqkynoteplj34jxyospr2rh9lpyd8zrsl0&t=632812333820000000
In addition, MS provides a header class. The header class is primarily the operation of the Oh. It's very easy to change the title of a page in the future.
This. Header.title = "This is the new page Title.";
Add CSS style (style attribute) style style = new style ();
Style. ForeColor = System.Drawing.Color.Navy;
Style. BackColor = System.Drawing.Color.LightGray;
ADD the style to the header for the "Body of the" page
This. Header.StyleSheet.CreateStyleRule (style, NULL, "body");
protected override void OnPreRender (EventArgs e) {
Get a WebResource URL for the core JS script and register it
This. Page.ClientScript.RegisterClientScriptResource (typeof (NumericTextBox),
"Obies.Web.UI.WebControls.NumericTextBox.js");
Get a WebResource URL for the embedded CSS
String CSS = this. Page.ClientScript.GetWebResourceUrl (typeof (NumericTextBox),
"Obies.Web.UI.WebControls.NumericTextBox_" + this. ImageSet + ". css");
Register the CSS
This. Page.stylesheettheme = CSS;
This. PAGE.HEADER.LINKEDSTYLESHEETS.ADD (CSS);
Previous versions of the method? You can only use the following code to solve the
Htmllink link = new Htmllink ();
Link. Attributes.Add ("type", "text/css");
Link. Attributes.Add ("rel", "stylesheet");
Link. Attributes.Add ("href", CSS);
This. PAGE.HEADER.CONTROLS.ADD (link);
}
Here's a screenshot of the micro-control piece.
How to use:
<%@ register tagprefix= "CC" namespace= "Obies.Web.UI.WebControls" assembly= "Obies.Web.UI.WebControls"%>
<cc:numerictextbox width= "imageset=" Silver length= "2" runat= "Server" id= "NumericTextBox1"
Maxvalue= "Ten" minvalue= "0" ></cc:NumericTextBox>
<cc:numerictextbox width= "imageset=" "Green" length= "2" runat= "Server" id= "NumericTextBox2"
Maxvalue= "Ten" minvalue= "0" ></cc:NumericTextBox>
Source Address:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
Dnvs05/html/webresource.asp
Because the original code has a problem, many features are the latest VS2005 not supported. So it was modified.
SOURCE Download:http://www.cnblogs.com/Files/cnzc/PostWebFormBetweenFrames.zip
There is a lot of information to be found in writing this article. Also try to write with heart. But it always feels like writing is not very good. There are also related WebResource on the Internet. However, many of them are not supported by the current version. I don't know if it was a previous asp.net2.0 earlier version. That's why we made a simple change.
After the effort.