Tutorials to .com

Tutorials to .com » Dotnet » Foundation » ASP.NET page template to achieve

ASP.NET page template to achieve

Print View , by: iSee ,Total views: 9 ,Word Count: 475 ,Date: Fri, 21 Aug 2009 Time: 10:00 PM

Programmers used JavaStruts should know, Struts, there is a template tag, although its use is more complex, but a large number of pages for the procedures for bringing a lot of its convenience. However, there is no ready-made ASP.NET can be used to achieve in this area rarely discussed internally, in fact, rewrite the sender method we can also achieve similar functions. The following is the project I used a base class template classes.

1using System;
2using System.Web.UI;
3
4namespace RepeaterDemo.Web.PageTemplate
5 (
6 /**//// <summary>
7 / / / WebPageTmplate page template base class.
8 / / / </ summary>
9 public class WebPageTmplate: System.Web.UI.Page
10 (
11
# Region Properties 12 Properties
13 string pageTitle = "Title";
14 string pageHeader = "<table cellspacing ='0 'cellpadding ='0' width ='100% 'height ='49' background = 'http://localhost//RepeaterDemo//Images/top_stripe1.gif' border = ' 0 '> "+
15 "<tr>" +
16 "<td valign='top'> <img alt =''src =" http://www.uudo.net/UpLoadFiles/Files/../UpPic/2007-4/21/0742112401014259.gif "border = '0 '> </ td> "+
17 "</ tr>" +
18 "</ table>";
19 string pageScript;
20
21 string pageLeft = "Menu";
22
23 string pageFooter = "<div align='center'> meil.cnblogs.com meil Copyright 2006 </ div>";
24
25
26 public string PageTitle
27 (
28 set (pageTitle = value;)
29 get (return pageTitle;)
30)
31
32 public string PageHeader
33 (
34 set (pageHeader = value;)
35 get (return pageHeader;)
36)
37
38 public string PageScript
39 (
40 set (pageScript = value;)
41 get (return pageScript;)
42)
43
44 public string PageLeft
45 (
46 set (pageLeft = value;)
47 get (return pageLeft;)
48)
49
50 public string PageFooter
51 (
52 set (pageFooter = value;)
53 get (return pageFooter;)
54)
55
56 # endregion
57
58 protected override void Render (HtmlTextWriter writer)
59 (
60
61
62 writer.Write (@ "<html> <head> <title>" + pageTitle + @ "</ title>");
63 writer.Write (pageScript + @ "</ head> <body>");
64
65 writer.Write (pageHeader);
66
67 writer.Write (@ "<table> <tr> <td width='200'>" + pageLeft + @ "</ td> <td>");
68
69 / / followed by a base class to allow ASPX page in HTML code and ASP.NET controls
70 base.Render (writer);
71
72 writer.Write ( "</ td> </ tr> </ table>");
73
74 writer.Write (@ "<div align='cnter'>" + pageFooter + @ "</ div>");
75
76 writer.Write (@"</ body> </ html> ");
77)
78)
79
80)
81
82
http://meil.cnblogs.com/archive/2006/06/22/432709.html


.NET foundation Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.