|
HTML clipboard
using System;
using System.IO;
namespace HTMLControls.Controls
{
public class Draw_StartHTMLHeader : System.Web.UI.UserControl
{
public string _title = "";
public string _charset = "";
public string _styles = "";
public string Title
{
set { _title = value; }
}
public string Charset
{
set { _charset = value; }
}
public string Styles
{
set { _styles = value; }
}
}
}
new Date();
self.status = today.toLocaleString();
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional
<html>
<head>
<title><%=_title %></title>
<meta http-equiv="content-type" content="text/html;
charset=<%=_charset %>">
<meta http-equiv="expires" content="-1">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<!----- ******* STYLES ********* --------------->
<link rel="stylesheet" href="<%=_styles %>" type="text/css">
Clock();
function Clock()
{
window.setTimeout("Clock()", 1000);
today =
<script language="JavaScript"
src="../Javascript/Status.js"></script>
</body>
</html>
Footer, besides trivial ending of HTML, shows real time in Status Bar

Header gives us the possibility to use a single line of code instead of 10
(title, charset, styles - parameters) Pay attention to Codebehind. Easy!
Graphical resizable frames around tables.
In order to fill our interface with data lets write class Person
Person.cs
using System;
using System.Web;
using System.Collections;
namespace HTMLControls.Components
{
public class Person : System.Web.UI.Page
{
int _age = 0;
string _name = "";
public Person()
{
}
public Person(string name, int age)
{
this._name = name;
this._age = age;
}
public int Age
{
get { return _age; }
set
{
if (value < 0)
throw new ArgumentException("The
age must be a positive number");
_age = value;
}
}
public string Name
{
get { return _name; }
set { _name = value; }
}
}
}
Many times we need to draw beautiful frame, lets say around the table, frame
has to be resizable in horizontal and vertical axis.
In order to do this we need to cut gifs in the right way (ask web designer) 4
corners and 4 square bars fragments (uf...) And write a code, there would be
many of it. :(

But we will do it another way:
<tr>
<td><img src="../Images/Desktop/left_up_corner.gif"
border="0"></td>
<td background="../Images/Desktop/up_border.gif"
border="0"><img src="../Images/1px_0.gif"
border="0"></td>
<td><img src="../Images/Desktop/right_up_corner.gif"
border="0"></td>
</tr>
<tr>
<td background="../Images/Desktop/left_border.gif"
border="0"
width="4"><img src="../Images/1px_0.gif"
border="0"
style="width:4px;"></td>
<td>
.............................
.............................
.............................
</td>
<td background="../Images/Desktop/right_border.gif"
border="0"
width="4"><img src="../Images/1px_0.gif"
border="0"
style="width:4px;"></td>
</tr>
<tr>
<td><img src="../Images/Desktop/left_down_corner.gif"
border="0"></td>
<td background="../Images/Desktop/down_border.gif"
border="0"><img src="../Images/1px_0.gif"
border="0"></td>
<td><img src="../Images/Desktop/right_down_corner.gif"
border="0"></td>
</tr>
The order in the page is the following:
1. Open table < table >
2. Draw_UpBorder, Draw_BorderStart - the order is significant
3. Table with Data
4. Draw_BorderEnd, Draw_EndBorder - the order is significant
5. Close table < / table >
Lets test:
using System;
using System.Collections;
using HTMLControls.Components;
namespace HTMLControls.Main
{
public class FirstPage : System.Web.UI.Page
{
protected
System.Web.UI.WebControls.DataGrid gridPerson;
void Page_Load(object
sender, EventArgs e)
{
ArrayList coll =
new ArrayList();
coll.Add(new
Person("Person 1", 10));
coll.Add(new
Person("Person 2", 20));
coll.Add(new
Person("Person 3", 30));
coll.Add(new
Person("Person 4", 40));
coll.Add(new
Person("Person 5", 50));
coll.Add(new
Person("Person 6", 60));
coll.Add(new
Person("Person 7", 10));
coll.Add(new
Person("Person 8", 20));
coll.Add(new
Person("Person 9", 30));
coll.Add(new
Person("Person 10", 40));
gridPerson.DataSource = coll;
gridPerson.DataBind();
}
}
}
<%@ Page language="c#" CodeBehind="FirstPage.aspx.cs"
Inherits="HTMLControls.Main.FirstPage"
%>
<%@ Import Namespace="HTMLControls.Components" %>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_StartHTMLHeader"
src="../Controls/Draw_StartHTMLHeader.ascx" %>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_UpBorder"
src="../Controls/Draw_UpBorder.ascx"
%>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_BorderStart"
src="../Controls/Draw_BorderStart.ascx"
%>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_BorderEnd"
src="../Controls/Draw_BorderEnd.ascx"
%>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_EndBorder"
src="../Controls/Draw_EndBorder.ascx"
%>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_HTMLFooter"
src="../Controls/Draw_HTMLFooter.ascx"
%>
<HTMLControls:Draw_StartHTMLHeader Charset="ISO-8859-1"
Title="FirstPage" Styles="../CSS/graphics.css" runat="server"
/>
</head>
<body class="lightBackGround" style="overflow:hidden;">
<form id="lg" name="lg" method="post" runat="server">
<table cellpadding="0" cellspacing="0" border="0" width="450"
align="center">
<HTMLControls:Draw_UpBorder runat="server" />
<HTMLControls:Draw_BorderStart runat="server" />
<table align="center" border="0" width="100%" cellspacing="0"
cellpadding="0" class="whiteBackGround">
<tr height="30"><td class="header">
First Page </td></tr>
<tr><td bgcolor="#336699"><img src="../Images/1px_0.gif"
border="0"></td></tr>
<tr>
<td>
<asp:DataGrid EnableViewState="false"
class="data"
id="gridPerson" AutoGenerateColumns="false"
runat="server">
<Columns>
<asp:TemplateColumn HeaderStyle-Font-Bold="true"
HeaderText="<span
style='padding-left:20px;'
>Name</span>" ItemStyle-Width="250">
<ItemTemplate><span style="padding-left:20px;"
><%# ((Person)Container.DataItem).Name
%></span></ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderStyle-Font-Bold="true"
HeaderText="<span
style='padding-left:20px;'
>Age</span>" ItemStyle-Width="200">
<ItemTemplate><span style="padding-left:20px;"
><%# ((Person)Container.DataItem).Age
%>
</span></ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</td>
</tr>
</table>
<HTMLControls:Draw_BorderEnd runat="server" />
<HTMLControls:Draw_EndBorder runat="server" />
</table>
</form>
<HTMLControls:Draw_HTMLFooter runat="server" />
Thats it.
SecondPage.aspx The second example is more complicated.
I wasted 1 minute to do it, using Copy-Paste

Lets test:
Columns>
</asp:DataGrid>
<HTMLControls:Draw_BorderEnd runat="server" />
<HTMLControls:Draw_EndBorder runat="server" />
</table>
</td>
</tr>
<tr>
<td style="padding:10px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%"
align="center">
<HTMLControls:Draw_UpBorder runat="server" />
<HTMLControls:Draw_BorderStart runat="server" />
<asp:DataGrid EnableViewState="false" class="data"
id="gridPerson3" AutoGenerateColumns="false"
runat="server">
<Columns>
<asp:TemplateColumn HeaderStyle-Font-Bold="true"
HeaderText="<span style='padding-left:20px;'
>Name</span>" ItemStyle-Width="200">
<ItemTemplate><span style="padding-left:20px;"
><%# ((Person)Container.DataItem).Name
%></span></ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderStyle-Font-Bold="true"
HeaderText="<span style='padding-left:20px;'
>Age</span>" ItemStyle-Width="150">
<ItemTemplate><span style="padding-left:20px;"
><%# ((Person)Container.DataItem).Age
%></span></ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<HTMLControls:Draw_BorderEnd runat="server" />
<HTMLControls:Draw_EndBorder runat="server" />
</table>
</td>
<td style="padding:10px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%"
align="center">
<HTMLControls:Draw_UpBorder runat="server" />
<HTMLControls:Draw_BorderStart runat="server" />
<asp:DataGrid EnableViewState="false" class="data" id="gridPerson4"
AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateColumn HeaderStyle-Font-Bold="true"
HeaderText="<span style='padding-left:20px;'
>Name</span>" ItemStyle-Width="200">
<ItemTemplate><span style="padding-left:20px;"
><%# ((Person)Container.DataItem).Name
%></span></ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderStyle-Font-Bold="true"
HeaderText="<span style='padding-left:20px;'
>Age</span>" ItemStyle-Width="150">
<ItemTemplate><span style="padding-left:20px;"
><%# ((Person)Container.DataItem).Age
%></span></ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<HTMLControls:Draw_BorderEnd runat="server" />
<HTMLControls:Draw_EndBorder runat="server" />
</table>
</td>
</tr>
</table>
<HTMLControls:Draw_BorderEnd runat="server" />
<HTMLControls:Draw_EndBorder runat="server" />
</table>
</form>
<HTMLControls:Draw_HTMLFooter runat="server" />
<%@ Page language="c#" CodeBehind="SecondPage.aspx.cs"
Inherits="HTMLControls.Main.SecondPage" %>
<%@ Import Namespace="HTMLControls.Components" %>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_StartHTMLHeader"
src="../Controls/Draw_StartHTMLHeader.ascx" %>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_UpBorder"
src="../Controls/Draw_UpBorder.ascx" %>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_BorderStart"
src="../Controls/Draw_BorderStart.ascx" %>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_BorderEnd"
src="../Controls/Draw_BorderEnd.ascx" %>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_EndBorder"
src="../Controls/Draw_EndBorder.ascx" %>
<%@ Register TagPrefix="HTMLControls" TagName="Draw_HTMLFooter"
src="../Controls/Draw_HTMLFooter.ascx" %>
<HTMLControls:Draw_StartHTMLHeader Charset="ISO-8859-1"
Title="SecondPage" Styles="../CSS/graphics.css"
runat="server" />
</head>
<body class="lightBackGround" style="overflow:hidden;">
<form id="lg" name="lg" method="post" runat="server">
<table cellpadding="0" cellspacing="0" border="0" width="100%"
align="center">
<HTMLControls:Draw_UpBorder runat="server" />
<HTMLControls:Draw_BorderStart runat="server" />
<table align="center" border="0" width="100%" cellspacing="0"
cellpadding="0" class="whiteBackGround">
<tr height="30"><td class="header" colspan="2">
Second Page </td></tr>
<tr><td bgcolor="#336699" colspan="2"><img
src="../Images/1px_0.gif" border="0"></td></tr>
<tr>
<td style="padding:10px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%"
align="center">
<HTMLControls:Draw_UpBorder runat="server" />
<HTMLControls:Draw_BorderStart runat="server" />
<asp:DataGrid EnableViewState="false" class="data"
id="gridPerson1" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateColumn HeaderStyle-Font-Bold="true"
HeaderText="<span style='padding-left:20px;'
>Name</span>" ItemStyle-Width="200">
<ItemTemplate><span style="padding-left:20px;"
><%# ((Person)Container.DataItem).Name
%></span></ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderStyle-Font-Bold="true"
HeaderText="<span style='padding-left:20px;'
>Age</span>" ItemStyle-Width="150">
<ItemTemplate><span style="padding-left:20px;"
><%# ((Person)Container.DataItem).Age
%></span></ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<HTMLControls:Draw_BorderEnd runat="server" />
<HTMLControls:Draw_EndBorder runat="server" />
</table>
</td>
<td style="padding:10px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%"
align="center">
<HTMLControls:Draw_UpBorder runat="server" />
<HTMLControls:Draw_BorderStart runat="server" />
<asp:DataGrid EnableViewState="false" class="data"
id="gridPerson2" AutoGenerateColumns="false"
runat="server">
<Columns>
<asp:TemplateColumn HeaderStyle-Font-Bold="true"
HeaderText="<span style='padding-left:20px;'
>Name</span>" ItemStyle-Width="200">
<ItemTemplate><span style="padding-left:20px;"
><%# ((Person)Container.DataItem).Name
%></span></ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderStyle-Font-Bold="true"
HeaderText="<span style='padding-left:20px;'
>Age</span>" ItemStyle-Width="150">
<ItemTemplate><span style="padding-left:20px;"
><%# ((Person)Container.DataItem).Age
%></span></ItemTemplate>
</asp:TemplateColumn>
</
|