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 4 1114
This is how the web works, it is stateless - designed to forget it's past.
You would need to explicitly store it somewhere to persist the info.
regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits/default.htm
"Free" <gu*************@geac.com> wrote in message
news:3f*********************@news.free.fr... 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
This is how the web works, it is stateless - designed to forget it's past.
You would need to explicitly store it somewhere to persist the info.
regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits/default.htm
"Free" <gu*************@geac.com> wrote in message
news:3f*********************@news.free.fr... 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 had the same problem. I couldn't find my previous post, but you need to
add the variable to the viewstate. The viewstate syntax is the same as the
session object, but the viewstate is stored on the page in encrypted form.
Viewstate("Value") = myVariable
myVariable = Viewstate("Value")
"Free" <gu*************@geac.com> wrote in message
news:3f*********************@news.free.fr... 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 had the same problem. I couldn't find my previous post, but you need to
add the variable to the viewstate. The viewstate syntax is the same as the
session object, but the viewstate is stored on the page in encrypted form.
Viewstate("Value") = myVariable
myVariable = Viewstate("Value")
"Free" <gu*************@geac.com> wrote in message
news:3f*********************@news.free.fr... 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Leo |
last post by:
Hi,
I'm back to ASP for a short while and I was wondering how
I could save the entire Application/Session-state to a
file or database and how to read it back afterwards. I'd
like to preserve...
|
by: Free |
last post by:
Hi,
I have a question about ASP.NET :
Here is an example of WebForm code. 2 buttons and 1 textbox.
----------------------------------------------------------------------------...
|
by: Tim Zych |
last post by:
If I declare a procedure in a webform as Public and attach it to a button in
the same webform, it runs fine. If I change it to Private Sub and try to
click it i get the error:
...
|
by: Mark Olbert |
last post by:
I'm confused about the behavior of inherited WebForms under VS/NET 2003.
In the Windows.Forms world, if I create a UserControl with a protected component on it, that
protected component is...
|
by: Craig Douthitt via DotNetMonster.com |
last post by:
I am trying to capture an buttonclick on a usercontrol in the webform the usercontrol resides in. After researching this issue, I've come to believe that the best way of handling this is by raising...
|
by: Dean Slindee |
last post by:
Would like to call the TabShow function on WebForm InOutHost from another
WebForm in same project, but cannot figure out how to get a reference. Can
this be done? In this statement: Call...
|
by: bigdadro |
last post by:
I've created a new class using prototype.js. After I make the
ajax.request all references to this.myClassMethodorVariable are lost.
Does the ajax method blow out the object persistance? I'm fairly...
|
by: Max |
last post by:
Please somebody can shed a light...
How can I have a variable visible and modifiable, inside one and only
webform?
I mean , I d like to see that variable from all the Sub of that webform
code,...
|
by: =?Utf-8?B?UGF1bA==?= |
last post by:
Hi I have start web form and when the user clicks a button (server.transfer)
they are directed to the second webform. I was wondering if there is a way
to create an instance of the first webform...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |