Now. Many developers are already using the webresource feature of ASP. net2.0. Webresource allows us to embed resourcesProgramCentralized. Including images and text.
We have to introduce webresource. axd when introducing webresource. Let's take a look.
Script Language = "JavaScript" src = "webresource. axd? A = S & R = webuivalidation. JS & t = 631944362841472848 "type =" text/JavaScript "> </SCRIPT> currently, I have discovered webresource. the axd parameters are different from the current version. In the early daysArticleIntroduction attributes:
Assembly a name
R resource file name
T Assembly last modification time
Webresource. axd is only a ising in ISAPI. You can also use ihttphandler. <Add verb = "get" Path = "webresource. axd "type =" system. web. handlers. assemblyresourceloader "/> webresource. the axd uses the assemblyresourceloader class to customize the processing of HTTP requests. It identifies the resource from which the query is sent based on the Program passed by the query.
The following uses the fine-tuning control as an example.
usage steps:
Add the resource to be embedded to the item
in resource manager, click File and in the Property Window (Properties window) in build action, select embedded Resource (embedded resource ).
Add the following files to your assessbly. in the 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 ")] Pay Attention to the webresourceattribute format:
[Assembly: webresourceattribute ("mynamespaces.resources.myimage.gif", "image/GIF")]
Control source code. You need to use the Code below to obtain the image
// get webresource URLs for the embedded GIF images
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. (obtain URL references to server resources)
I found that in earlier versions. Its usage is: This. Page. getwebresourceurl
The above code obtains the image name obies from the specified assembly. web. UI. webcontrols. numerictextbox _ "+ this. imageset. tostring () + "_btnup.gif, which returns the URL reference address of a server-side resource. Similar:
Webresource. axd? D = gwyjblnqkynoteplj34jxyospr2rh9lpyd8zrsl0 & t = 632812333820000000
In addition, Ms provides a header class. The header class is mainly used for Haha. It is very easy to modify the title of a page in the future.
This. header. Title = "this is the new page title .";
Add a CSS style (style attribute) 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 );
// Method of earlier versions? The following code can only be used to solve the problem.
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 );
}
Below is the fine-tuned control
Usage:
<% @ Register tagprefix = "cc" namespace = "obies. Web. UI. webcontrols" assembly = "obies. Web. UI. webcontrols" %>
<CC: numerictextbox width = "50" imageset = "Silver" length = "2" runat = "server" id = "numerictextbox1"
Maxvalue = "10" minvalue = "0"> </CC: numerictextbox>
<CC: numerictextbox width = "50" imageset = "green" length = "2" runat = "server" id = "numerictextbox2"
Maxvalue = "10" 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 some problems, many features are not supported by the latest vs2005. So the modification was made.
Source code download: http://www.cnblogs.com/Files/cnzc/PostWebFormBetweenFrames.zip
I found a lot of information in this article. Also try to write with your heart. But I always feel that it is not well written. There are also related webresource introductions on the Internet. However, many of them are currently not supported by the latest version. I don't know if it was an earlier version of ASP. net2.0. So we made a simple modification.
I am working hard later.