regarding variables declared in a page
-
hi i worked on windows application and now i m working on web application for the first time. the following is my code in defalut page Partial Class _Default Inherits System.Web.UI.Page Dim i As Integer = 0 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click i = i + 1 MsgBox(i.ToString()) End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click i = i * 100 MsgBox(i.ToString()) End Sub End Class when i click button1 the value in i is 1. but when i click button2,it is showing the value in i is 0 but ihave to get 100 can any one tell me whats happening at button2
-
hi i worked on windows application and now i m working on web application for the first time. the following is my code in defalut page Partial Class _Default Inherits System.Web.UI.Page Dim i As Integer = 0 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click i = i + 1 MsgBox(i.ToString()) End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click i = i * 100 MsgBox(i.ToString()) End Sub End Class when i click button1 the value in i is 1. but when i click button2,it is showing the value in i is 0 but ihave to get 100 can any one tell me whats happening at button2
First, format your code using the pre tags when posting. You've been around long enough to know this. Understand that the web, and ASP.NET, is stateless. Each time a page is requested, or an action, such as a button click, causes a postback, all the variables you have declared are set to their default values unless otherwise persisted. You will do well to pick up a book on ASP.NET and read it before proceeding.
I know the language. I've read a book. - _Madmatt
-
hi i worked on windows application and now i m working on web application for the first time. the following is my code in defalut page Partial Class _Default Inherits System.Web.UI.Page Dim i As Integer = 0 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click i = i + 1 MsgBox(i.ToString()) End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click i = i * 100 MsgBox(i.ToString()) End Sub End Class when i click button1 the value in i is 1. but when i click button2,it is showing the value in i is 0 but ihave to get 100 can any one tell me whats happening at button2