Training-2.aspx.vb
Public Class Training_2
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents submit1 As System.Web.UI.HtmlControls.HtmlInputButton
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox3 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Button3 As System.Web.UI.WebControls.Button
Protected WithEvents Button4 As System.Web.UI.WebControls.Button
Protected WithEvents Button5 As System.Web.UI.WebControls.Button
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim T1 As New TextBox
Dim B1 As New Button
T1.CssClass = "B2"
T1.Text = "Microsoft"
B1.CssClass = "b2"
B1.Text = "Test5"
Panel1.Controls.Add(T1)
Panel1.Controls.Add(B1)
AddHandler B1.Click, AddressOf Btn_Click
End Sub
Private Sub Btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
TextBox1.Text = "Phanuwat"
TextBox2.Text = "Raunmoon"
Dim b1 As Button
b1 = CType(sender, Button)
TextBox3.Text = b1.Text
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
TextBox1.Text = "Microsoft"
TextBox2.Text = "Visual Basic .NET"
End Sub
Private Sub submit1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit1.ServerClick
TextBox1.Text = "London"
TextBox2.Text = "Now York"
End Sub
Private Sub submit1_ServerClick1(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit1.ServerClick
' TextBox1.Text = "London"
' TextBox2.Text = "New York"
End Sub
End Class
เวลา run จะฟ้อง error ว่า Error expect';' ดังนั้นผมจึงเพิ่ม ; ในบรรทัด
<INPUT language="javascript" id="submit1" onclick="return submit1_onclick(); " type="button"
value="Test7" runat="server">
ถึงจะ run ผ่าน และไปทำงานใน ฟังชัน submit1_onclick() แต่หลังจากนั้นก็ไม่ไปทำงานที่ ฝั่ง server ต่อครับ
ผมไม่ทราบว่าทำไมไม่ไปทำงานที่ฝั่ง server นะครับ