Summary: Take a news website page as an example, combined with the ASP.NET characteristics, the method of multiplexing the web page is introduced.
Abstract: This Paper Introduces Some Methods of Reusable Web Page Which Combining with the Features of ASP.NET, AND TAKING A Web Page of A News Web Site as an example.
Keywords: ASP.NET multiplex user control inheritance
Key Words: ASP.NET Reusable User Controls Inherit
0 Preface
With the continuous development of the network, the web-based B / S architecture is the mainstream of the current application, where business logic and databases are placed in such architectures, and the user operates the server's data through the browser. Before the Microsoft.Net platform has not been launched, people can achieve the above objects through the ASP, and now you can choose ASP.NET.
ASP.NET is a compiled, based .NET-based environment that creates applications with any .NET compatible language (including Visual Basic.net, C #, and JScript.net.). Any ASP.NET application can use the entire .NET Framework. In contrast, the ASP is an interpreted programming framework. The scripting language is VBScript and JavaScript. These two languages are limited. They need to use components written in languages such as C , Java to extend their functions, and the interpretation is running , Limited efficiency.
1. Problem
A website, especially those combined with the database, such as news websites, product introduction websites, etc.), there are many pages similar, different only data related to the database (such as different news content, different products, etc.) . We don't have to write a file for each page, the cost of doing is too high, we can fix the constant part, and the changed part is dynamically generated according to the client request.
Take a news website page containing header, footer, and navigation bar. The sample page is as follows:
2, solution
The concept of web form user controls is introduced in ASP.NET, which uses it to easily create custom reusable controls. The user control can be compiled and stored in the server memory during the first request, which can shorten the response time of the subsequent request. User control inherits from System.Web.ui.userControl. We can make headers, footers, and navigation columns into user controls.
For simplicity, the header only contains a picture pointing to the home page. The new file Header.ascx is as follows:
<% @ Control%>
a >
td> TR> table> Footers are two lines of text, implemented with a list of two lines. New files FOOTER.ASCX, the content is as follows: <% @ Control%>
|