F
Free
Hi,
I have a question about ASP.NET :
Here is an example of WebForm code. 2 buttons and 1 textbox.
----------------------------------------------------------------------------
-----------------------
Public Class MyWebPage
Inherits System.Web.UI.Page
Protected WithEvents MyButton1 As System.Web.UI.WebControls.Button
Protected WithEvents MyButton2 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
' Web Form Designer Generated Code
Private m_strMyString As String
Private Sub MyButton1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyButton1.Click
m_strMyString = "Hello"
End Sub
Private Sub MyButton2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyButton2.Click
TextBox1.Text = m_strMyString
End Sub
End Class
----------------------------------------------------------------------------
-------------------------
When I click MyButton1, I set m_strMyString to "Hello" but after that, if I
click on MyButton2, m_strMyString is Nothing.
Each time I return to server all variables are erased.
Is it normal ?
Is ther a way to correct this without using Session variables or shared
variables ?
Thanks a lot
Guillaume
I have a question about ASP.NET :
Here is an example of WebForm code. 2 buttons and 1 textbox.
----------------------------------------------------------------------------
-----------------------
Public Class MyWebPage
Inherits System.Web.UI.Page
Protected WithEvents MyButton1 As System.Web.UI.WebControls.Button
Protected WithEvents MyButton2 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
' Web Form Designer Generated Code
Private m_strMyString As String
Private Sub MyButton1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyButton1.Click
m_strMyString = "Hello"
End Sub
Private Sub MyButton2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyButton2.Click
TextBox1.Text = m_strMyString
End Sub
End Class
----------------------------------------------------------------------------
-------------------------
When I click MyButton1, I set m_strMyString to "Hello" but after that, if I
click on MyButton2, m_strMyString is Nothing.
Each time I return to server all variables are erased.
Is it normal ?
Is ther a way to correct this without using Session variables or shared
variables ?
Thanks a lot
Guillaume