search
HomeBackend DevelopmentC#.Net TutorialASP.NET2.0 WebRource, developing spinner control

Now. Many developers are already using the WebResource functionality of ASP.NET 2.0. WebResource allows us to embed resources into assemblies. Includes images, text, etc.

When 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="text/javascript">Currently I found that the parameters of webResource.axd are different from the current version. In an earlier article, attributes were introduced:
a Assembly name
r Resource file name
t Assembly last modified time


webResource.axd is just one in ISAPI mapping. You can also use IhttpHandler. webResource.axd uses the AssemblyResourceLoader class to customize processing of HTTP requests, and is identified according to the program passed by the query Which resource is obtained from which assembly.

The following uses the fine-tuning control as an example.

Usage steps:
Add the resources to be embedded (such as images) to the item
In the resource manager, click the file, select embedded resource in the build action in the property window (property window) (embedded resource).
Add the following files 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")] Please note the WebResourceAttribute format:
[assembly: WebResourceAttribute("MyNameSpaces.Resources.MyImage.gif", "image /gif")]
is in the CONTROL source code. You need to use the following code to get the images
// 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.(Gets a URL reference to a server-side resource)
I found that in in earlier versions. Its usage is: this.page.GetWebResourceUrl

The above code gets 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 mainly operates on

in HTML pages. Including Title etc.
Haha. It will be very easy to modify 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); 
//早期版本的方法?只能用下面的代码来解决了
            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);

        }      
下面是微调控件的截图

使用方法:

maxvalue="10" minvalue="0">
maxvalue="10" minvalue="0">

来源地址:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
dnvs05/html/webresource.asp
由于原来的代码有点问题,很多特性都是最新VS2005不支持的。所以进行了修改。
源码下载:http://www.cnblogs.com/Files/cnzc/PostWebFormBetweenFrames.zip

在写这篇文章查了很多资料。也尝试用心去写。但总感觉写的不是很好。网上也有相关的webresource的介绍。但发现很多都是目前最新版本不支持的。不知道是不是以前ASP.NET2.0早期版本。所以才进行了简单的修改。
以后在努力了。

The above is the detailed content of ASP.NET2.0 WebRource, developing spinner control. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
C# .NET in the Modern World: Applications and IndustriesC# .NET in the Modern World: Applications and IndustriesMay 08, 2025 am 12:08 AM

C#.NET is widely used in the modern world in the fields of game development, financial services, the Internet of Things and cloud computing. 1) In game development, use C# to program through the Unity engine. 2) In the field of financial services, C#.NET is used to develop high-performance trading systems and data analysis tools. 3) In terms of IoT and cloud computing, C#.NET provides support through Azure services to develop device control logic and data processing.

C# .NET Framework vs. .NET Core/5/6: What's the Difference?C# .NET Framework vs. .NET Core/5/6: What's the Difference?May 07, 2025 am 12:06 AM

.NETFrameworkisWindows-centric,while.NETCore/5/6supportscross-platformdevelopment.1).NETFramework,since2002,isidealforWindowsapplicationsbutlimitedincross-platformcapabilities.2).NETCore,from2016,anditsevolutions(.NET5/6)offerbetterperformance,cross-

The Community of C# .NET Developers: Resources and SupportThe Community of C# .NET Developers: Resources and SupportMay 06, 2025 am 12:11 AM

The C#.NET developer community provides rich resources and support, including: 1. Microsoft's official documents, 2. Community forums such as StackOverflow and Reddit, and 3. Open source projects on GitHub. These resources help developers improve their programming skills from basic learning to advanced applications.

The C# .NET Advantage: Features, Benefits, and Use CasesThe C# .NET Advantage: Features, Benefits, and Use CasesMay 05, 2025 am 12:01 AM

The advantages of C#.NET include: 1) Language features, such as asynchronous programming simplifies development; 2) Performance and reliability, improving efficiency through JIT compilation and garbage collection mechanisms; 3) Cross-platform support, .NETCore expands application scenarios; 4) A wide range of practical applications, with outstanding performance from the Web to desktop and game development.

Is C# Always Associated with .NET? Exploring AlternativesIs C# Always Associated with .NET? Exploring AlternativesMay 04, 2025 am 12:06 AM

C# is not always tied to .NET. 1) C# can run in the Mono runtime environment and is suitable for Linux and macOS. 2) In the Unity game engine, C# is used for scripting and does not rely on the .NET framework. 3) C# can also be used for embedded system development, such as .NETMicroFramework.

The .NET Ecosystem: C#'s Role and BeyondThe .NET Ecosystem: C#'s Role and BeyondMay 03, 2025 am 12:04 AM

C# plays a core role in the .NET ecosystem and is the preferred language for developers. 1) C# provides efficient and easy-to-use programming methods, combining the advantages of C, C and Java. 2) Execute through .NET runtime (CLR) to ensure efficient cross-platform operation. 3) C# supports basic to advanced usage, such as LINQ and asynchronous programming. 4) Optimization and best practices include using StringBuilder and asynchronous programming to improve performance and maintainability.

C# as a .NET Language: The Foundation of the EcosystemC# as a .NET Language: The Foundation of the EcosystemMay 02, 2025 am 12:01 AM

C# is a programming language released by Microsoft in 2000, aiming to combine the power of C and the simplicity of Java. 1.C# is a type-safe, object-oriented programming language that supports encapsulation, inheritance and polymorphism. 2. The compilation process of C# converts the code into an intermediate language (IL), and then compiles it into machine code execution in the .NET runtime environment (CLR). 3. The basic usage of C# includes variable declarations, control flows and function definitions, while advanced usages cover asynchronous programming, LINQ and delegates, etc. 4. Common errors include type mismatch and null reference exceptions, which can be debugged through debugger, exception handling and logging. 5. Performance optimization suggestions include the use of LINQ, asynchronous programming, and improving code readability.

C# vs. .NET: Clarifying the Key Differences and SimilaritiesC# vs. .NET: Clarifying the Key Differences and SimilaritiesMay 01, 2025 am 12:12 AM

C# is a programming language, while .NET is a software framework. 1.C# is developed by Microsoft and is suitable for multi-platform development. 2..NET provides class libraries and runtime environments, and supports multilingual. The two work together to build modern applications.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment