tablemain.aspx.cs
来自「csharp课本的源代码」· CS 代码 · 共 104 行
CS
104 行
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
//protected void Page_Load(object sender, EventArgs e)
//{
// AddRow("搜狐企业在线", "http://www.sohu.net",
// "包括招商引资、企业报道等信息。");
// AddRow("263在线", "http://www.263.net",
// "包括娱乐、生活、旅游等信息。");
//}
//private void AddRow(string str1, string url, string str2)
//{
// //产生一个行对象
// TableRow row = new TableRow();
// //产生一个HyperLink控件
// HyperLink hyperlink = new HyperLink();
// hyperlink.Text = str1;
// hyperlink.NavigateUrl = url;
// hyperlink.Target = "_top";
// //产生一个单元格对象
// TableCell cell1 = new TableCell();
// cell1.Font.Size = FontUnit.Large;
// //单元格中放入HyperLink控件对象
// cell1.Controls.Add(hyperlink);
// //行对象中加入一个单元格对象
// row.Cells.Add(cell1);
// //又产生一个单元格对象
// TableCell cell2 = new TableCell();
// cell2.Font.Size = FontUnit.Large;
// cell2.ForeColor = System.Drawing.Color.Blue;
// //单元格中放入文本
// cell2.Text = str2;
// //行对象中再加入一个单元格对象
// row.Cells.Add(cell2);
// //表中插入一行
// tableWeb.Rows.Add(row);
//}
private void AddRow(string str1, string url, string str2)
{
//产生一个行对象
TableRow row = new TableRow();
//产生一个HyperLink控件
HyperLink hyperlink = new HyperLink();
hyperlink.Text = str1;
hyperlink.NavigateUrl = url;
hyperlink.Target = "_top";
//产生一个单元格对象
TableCell cell1 = new TableCell();
cell1.Font.Size = FontUnit.Large;
//单元格中放入HyperLink控件对象
cell1.Controls.Add(hyperlink);
//行对象中加入一个单元格对象
row.Cells.Add(cell1);
//又产生一个单元格对象
TableCell cell2 = new TableCell();
cell2.Font.Size = FontUnit.Large;
cell2.ForeColor = System.Drawing.Color.Blue;
//单元格中放入文本
cell2.Text = str2;
//行对象中再加入一个单元格对象
row.Cells.Add(cell2);
//表中插入一行
tableWeb.Rows.Add(row);
}
//protected void buttonOK_Click(object sender, EventArgs e)
//{
// AddRow(textBoxName.Text, textBoxUrl.Text,
// textBoxInformation.Text);
// textBoxName.Text = "";
// textBoxUrl.Text = "http://";
// textBoxInformation.Text = "";
//}
protected void Page_Load(object sender, EventArgs e)
{
AddRow("搜狐企业在线", "http://www.sohu.net",
"包括招商引资、企业报道等信息。");
AddRow("263在线", "http://www.263.net",
"包括娱乐、生活、旅游等信息。");
}
protected void buttonOK_Click(object sender, EventArgs e)
{
AddRow(textBoxName.Text, textBoxUrl.Text,
textBoxInformation.Text);
textBoxName.Text = "";
textBoxUrl.Text = "http://";
textBoxInformation.Text = "";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?