我用代码在窗体中添加了一个表格(5行7列),如果要实现当鼠标移动到某个单元格时,指针会变成小手的形状,当单击某个单元格时,会加载一个新的页面并传值过去。请问这段代码该怎样加上啊。 我的代码如下: Private Sub aa(ByVal year As String, ByVal month As String)
Dim dt As DateTime = New DateTime(year, month, 1)
Dim w As Integer = CInt(dt.DayOfWeek) '获取是星期几
Dim curr As DateTime
Dim start As DateTime = dt.AddDays(-w)
Dim table As New Table
Dim trow As New TableRow
Dim tcell As New TableCell
If Conn.State = ConnectionState.Closed Then Conn.Open()
Comm.Connection = Conn
Dim Oreader As SqlDataReader Dim T1 As String = "", T2 As String = ""
Dim context As String, Cont As String Dim i As Int16 = 0
'************************添加星期
Cont = "<tr style='FONT-SIZE: large; COLOR: lightgoldenrodyellow; FONT-FAMILY: 宋体; TEXT-ALIGN: center' bgColor='sienna' ><td >星期日</td><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td><td>星期五</td><td>星期六</td></tr>"
trow = New TableRow
tcell = New TableCell
tcell.BorderWidth.Pixel(3)
tcell.Width = New Unit("14%")
tcell.Height.Pixel(100)
trow.Cells.Add(tcell)
tcell.Text = Cont
table.Rows.Add(trow)
While (i < 35)
curr = start.AddDays(i) '************************ 读取数据库 *******
Comm.CommandText = "select kh,ddh,jzh from tdd where cq='" & curr.ToShortDateString & "'"
Oreader = Comm.ExecuteReader
If Oreader.HasRows Then
While Oreader.Read
T1 = "<font color='Blue'>" & Oreader.GetValue(0) + "</font>" + " : " + "<font color='#804000'>" + Oreader.GetValue(1) + "</font>" + "(" + Oreader.GetValue(2) + ")" + "<font><br></font>"
T2 = T1 + T2
End While
End If
Oreader.Close()
'****************** context = "<table border='0' cellspacing='0' cellpadding='0' width='100%' height='100%'><tr><td bgcolor='#deb887'>{0}</td></tr> <tr><td height='80' width=100% height=100% style='position=absolute top=0 left=0' noWrap bgColor='#e5d8e6' background='image1/z5.gif' style='BACKGROUND-POSITION: center center; BACKGROUND-ATTACHMENT: scroll' >" & T2 & " </td></tr></table>"
If (i Mod 7 = 0) Then trow = New TableRow
tcell = New TableCell
tcell.BorderWidth.Pixel(1)
tcell.Width = New Unit("14%")
tcell.Height.Pixel(100)
trow.Cells.Add(tcell) If (start.AddDays(i).Month <> dt.Month) Then
tcell.Text = context.Replace("{0}", "<font color='AppWorkspace' >" + curr.Day.ToString() + "</font>") Else
tcell.Text = context.Replace("{0}", "<font >" + curr.Day.ToString() + "</font>")
End If
If (i Mod 7 = 0) Then table.Rows.Add(trow) If start.AddDays(i).Day = Now.Day Then tcell.Text = context.Replace("{0}", "<font color='red' >" + curr.Day.ToString() + "</font>") i = i + 1
T1 = ""
T2 = ""
End While
Conn.Close()
table.BorderWidth.Pixel(2)
table.CellSpacing = 0
table.Width = New Unit("100%")
Panel1.Controls.AddAt(5, table)
End Sub‘**********************************这是一个备忘录型的日期控件
Dim dt As DateTime = New DateTime(year, month, 1)
Dim w As Integer = CInt(dt.DayOfWeek) '获取是星期几
Dim curr As DateTime
Dim start As DateTime = dt.AddDays(-w)
Dim table As New Table
Dim trow As New TableRow
Dim tcell As New TableCell
If Conn.State = ConnectionState.Closed Then Conn.Open()
Comm.Connection = Conn
Dim Oreader As SqlDataReader Dim T1 As String = "", T2 As String = ""
Dim context As String, Cont As String Dim i As Int16 = 0
'************************添加星期
Cont = "<tr style='FONT-SIZE: large; COLOR: lightgoldenrodyellow; FONT-FAMILY: 宋体; TEXT-ALIGN: center' bgColor='sienna' ><td >星期日</td><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td><td>星期五</td><td>星期六</td></tr>"
trow = New TableRow
tcell = New TableCell
tcell.BorderWidth.Pixel(3)
tcell.Width = New Unit("14%")
tcell.Height.Pixel(100)
trow.Cells.Add(tcell)
tcell.Text = Cont
table.Rows.Add(trow)
While (i < 35)
curr = start.AddDays(i) '************************ 读取数据库 *******
Comm.CommandText = "select kh,ddh,jzh from tdd where cq='" & curr.ToShortDateString & "'"
Oreader = Comm.ExecuteReader
If Oreader.HasRows Then
While Oreader.Read
T1 = "<font color='Blue'>" & Oreader.GetValue(0) + "</font>" + " : " + "<font color='#804000'>" + Oreader.GetValue(1) + "</font>" + "(" + Oreader.GetValue(2) + ")" + "<font><br></font>"
T2 = T1 + T2
End While
End If
Oreader.Close()
'****************** context = "<table border='0' cellspacing='0' cellpadding='0' width='100%' height='100%'><tr><td bgcolor='#deb887'>{0}</td></tr> <tr><td height='80' width=100% height=100% style='position=absolute top=0 left=0' noWrap bgColor='#e5d8e6' background='image1/z5.gif' style='BACKGROUND-POSITION: center center; BACKGROUND-ATTACHMENT: scroll' >" & T2 & " </td></tr></table>"
If (i Mod 7 = 0) Then trow = New TableRow
tcell = New TableCell
tcell.BorderWidth.Pixel(1)
tcell.Width = New Unit("14%")
tcell.Height.Pixel(100)
trow.Cells.Add(tcell) If (start.AddDays(i).Month <> dt.Month) Then
tcell.Text = context.Replace("{0}", "<font color='AppWorkspace' >" + curr.Day.ToString() + "</font>") Else
tcell.Text = context.Replace("{0}", "<font >" + curr.Day.ToString() + "</font>")
End If
If (i Mod 7 = 0) Then table.Rows.Add(trow) If start.AddDays(i).Day = Now.Day Then tcell.Text = context.Replace("{0}", "<font color='red' >" + curr.Day.ToString() + "</font>") i = i + 1
T1 = ""
T2 = ""
End While
Conn.Close()
table.BorderWidth.Pixel(2)
table.CellSpacing = 0
table.Width = New Unit("100%")
Panel1.Controls.AddAt(5, table)
End Sub‘**********************************这是一个备忘录型的日期控件
td.style.cursor="hand";
var getTdValue=td.innerText;用这两个属性就可以获得你要的效果和参数:)
tmp.Style.Add("CURSOR","hand");
tmp.Attributes.Add("onclick", "window.location.href='webform2.aspx?a=1';")