80 likes | 245 Views
子母視窗傳值 by JS. 子母視窗傳值. Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click Dim funcWin_Open1 As String funcWin_Open1 = "<Script language=""JavaScript"">"
E N D
子母視窗傳值 • Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click • Dim funcWin_Open1 As String • funcWin_Open1 = "<Script language=""JavaScript"">" • funcWin_Open1 += "window.open('calendar.aspx?objName=TextBox1','日期','scrollbars=yes,resizable=yes,width=450,height=200');" • funcWin_Open1 += "</Script>" • Response.Write(funcWin_Open1) • End sub
子母視窗傳值 Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged Dim bb1 As String bb1 = Calendar1.SelectedDate.ToShortDateString() Response.Write("<script>window.opener.document.getElementById('" + Request("ObjName") + "').value='" + bb1 + "';") Response.Write("window.close();") Response.Write("</script>") End Sub
動態產生按鈕 Panel 1. 宣告此物件 Dim mybtn As System.Web.UI.WebControls.Button 2. 產生新按按鈕 mybtn = New Button() mybtn.ID = "btn1" mybtn.Text = "123" mybtn.Visible = True Panel1.Controls.Add(mybtn) AddHandler mybtn.Command, AddressOf Button_Command 事件 Protected Sub Button_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Label1.Text = "我是新按鈕" End Sub
動態產生Table '新增一列 Dim newrow As New TableRow Dim newcell1, newcell2, newcell3 As New TableCell newrow = New TableRow() '新增三欄 newcell1 = New TableCell() newcell2 = New TableCell() newcell3 = New TableCell() newcell1.Text = "a" newcell2.Text = "b" newcell3.Text = "c“ '將欄加入列 newrow.Cells.Add(newcell1) newrow.Cells.Add(newcell2) newrow.Cells.Add(newcell3) '將列併入表格 Table1.Rows.Add(newrow)
99乘法表 '新增一列 Dim newrow As New TableRow Dim i, j As Integer Dim newcell1 As New TableCell For i = 1 To 8 newrow = New TableRow() '新增欄 For j = 0 To 9 newcell1 = New TableCell() If j = 0 Then newcell1.Text = (i + 1).ToString() Else newcell1.Text = (j * (i + 1)).ToString() End If '將欄加入列 newrow.Cells.Add(newcell1) '將列併入表格 Next Table1.Rows.Add(newrow) Next