473,413 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Global variable.

Hi, Good Day!

I need to create a variable that it's value can be carry across within a
form.

I've created some above the "web form designer generated code" but it seems
not working.

It reset back to nothing when i click on a button.

Can someone help?
Thanks in advanced.

rgds,
Phoebe
Nov 20 '05 #1
8 1378
Public Class Form1
Private sTr as String
Private i as Integer
Nov 20 '05 #2
Your variables get reset when you click a button because the clicking of
that button causes the entire form to be re-created (and therefore reset).

In ASP.NET, by the time the client has received the web page, the server has
completed its processing of that page and unloaded it from memory. Each and
every time the page is requested again (which clicking a button would
cause), the page is created from scratch all over again.

The variables you created, are available anywhere in the programming of the
page, but only while the page is being processed.
"Phoebe." <ph********@hotmail.com> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
Hi, Good Day!

I need to create a variable that it's value can be carry across within a
form.

I've created some above the "web form designer generated code" but it seems not working.

It reset back to nothing when i click on a button.

Can someone help?
Thanks in advanced.

rgds,
Phoebe

Nov 20 '05 #3
Thanks Carno.

My situation is i have a edit in my datagrid and this trigger
Sub EditRec(Byval objsrc as object, byval objargs as
datagridcommandeventargs)
...
End Sub

I have a Update button which trigger
Sub UpdateRecord(byval sender as system.object, byval e as system.eventargs)
...
End Sub

I need to capture my previous record from Sub EditRec and compare them in
Sub UpdateRecord.

Any idea on how it works?
Thanks in advanced.

rgds,
Phoebe.

"Carno C. Mercado" <on***@webgate.net.ph> wrote in message
news:O$**************@tk2msftngp13.phx.gbl...
Public Class Form1
Private sTr as String
Private i as Integer
.
.

' Constructor
Public Sub New()
sTr = "Test"

End Sub

Public Sub Method1

' here you can see the value of sTr
if ( sTr = "Test ) then

end if

end sub

More Functions
End Class


"Phoebe." <ph********@hotmail.com> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
Hi, Good Day!

I need to create a variable that it's value can be carry across within a
form.

I've created some above the "web form designer generated code" but it

seems
not working.

It reset back to nothing when i click on a button.

Can someone help?
Thanks in advanced.

rgds,
Phoebe


Nov 20 '05 #4
In the DataGrid's EditCommand event handler use the eventArgs argument to
determine what row was edited (e.item?).
"Phoebe." <ph********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks Carno.

My situation is i have a edit in my datagrid and this trigger
Sub EditRec(Byval objsrc as object, byval objargs as
datagridcommandeventargs)
...
End Sub

I have a Update button which trigger
Sub UpdateRecord(byval sender as system.object, byval e as system.eventargs) ...
End Sub

I need to capture my previous record from Sub EditRec and compare them in
Sub UpdateRecord.

Any idea on how it works?
Thanks in advanced.

rgds,
Phoebe.

"Carno C. Mercado" <on***@webgate.net.ph> wrote in message
news:O$**************@tk2msftngp13.phx.gbl...
Public Class Form1
Private sTr as String
Private i as Integer
.
.

' Constructor
Public Sub New()
sTr = "Test"

End Sub

Public Sub Method1

' here you can see the value of sTr
if ( sTr = "Test ) then

end if

end sub

More Functions
End Class


"Phoebe." <ph********@hotmail.com> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
Hi, Good Day!

I need to create a variable that it's value can be carry across within a form.

I've created some above the "web form designer generated code" but it

seems
not working.

It reset back to nothing when i click on a button.

Can someone help?
Thanks in advanced.

rgds,
Phoebe



Nov 20 '05 #5
Thanks Scott.

But I need the data that pass to UpdateRecord for comparison.
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:eG**************@TK2MSFTNGP12.phx.gbl...
In the DataGrid's EditCommand event handler use the eventArgs argument to
determine what row was edited (e.item?).
"Phoebe." <ph********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks Carno.

My situation is i have a edit in my datagrid and this trigger
Sub EditRec(Byval objsrc as object, byval objargs as
datagridcommandeventargs)
...
End Sub

I have a Update button which trigger
Sub UpdateRecord(byval sender as system.object, byval e as system.eventargs)
...
End Sub

I need to capture my previous record from Sub EditRec and compare them in
Sub UpdateRecord.

Any idea on how it works?
Thanks in advanced.

rgds,
Phoebe.

"Carno C. Mercado" <on***@webgate.net.ph> wrote in message
news:O$**************@tk2msftngp13.phx.gbl...
Public Class Form1
Private sTr as String
Private i as Integer
.
.

' Constructor
Public Sub New()
sTr = "Test"

End Sub

Public Sub Method1

' here you can see the value of sTr
if ( sTr = "Test ) then

end if

end sub

More Functions
End Class


"Phoebe." <ph********@hotmail.com> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
> Hi, Good Day!
>
> I need to create a variable that it's value can be carry across within a > form.
>
> I've created some above the "web form designer generated code" but

it seems
> not working.
>
> It reset back to nothing when i click on a button.
>
> Can someone help?
> Thanks in advanced.
>
> rgds,
> Phoebe
>
>



Nov 20 '05 #6
Cor
Hi Phoebe

Have a look at "Session" variables and to "Viewstate"

I hope this helps

Cor
Nov 20 '05 #7
Yes, and the only way to do that is to know what record was just edited (see
my last post). Once you know what row of the grid was edited, you can use
FindControl to grab the data.
"Phoebe." <ph********@hotmail.com> wrote in message
news:ev**************@TK2MSFTNGP12.phx.gbl...
Thanks Scott.

But I need the data that pass to UpdateRecord for comparison.
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:eG**************@TK2MSFTNGP12.phx.gbl...
In the DataGrid's EditCommand event handler use the eventArgs argument to
determine what row was edited (e.item?).
"Phoebe." <ph********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks Carno.

My situation is i have a edit in my datagrid and this trigger
Sub EditRec(Byval objsrc as object, byval objargs as
datagridcommandeventargs)
...
End Sub

I have a Update button which trigger
Sub UpdateRecord(byval sender as system.object, byval e as

system.eventargs)
...
End Sub

I need to capture my previous record from Sub EditRec and compare them

in Sub UpdateRecord.

Any idea on how it works?
Thanks in advanced.

rgds,
Phoebe.

"Carno C. Mercado" <on***@webgate.net.ph> wrote in message
news:O$**************@tk2msftngp13.phx.gbl...
> Public Class Form1
> Private sTr as String
> Private i as Integer
> .
> .
>
> ' Constructor
> Public Sub New()
> sTr = "Test"
>
> End Sub
>
> Public Sub Method1
>
> ' here you can see the value of sTr
> if ( sTr = "Test ) then
>
> end if
>
> end sub
>
> More Functions
>
>
> End Class
>
>
>
>
> "Phoebe." <ph********@hotmail.com> wrote in message
> news:u7**************@TK2MSFTNGP11.phx.gbl...
> > Hi, Good Day!
> >
> > I need to create a variable that it's value can be carry across within
a
> > form.
> >
> > I've created some above the "web form designer generated code" but

it > seems
> > not working.
> >
> > It reset back to nothing when i click on a button.
> >
> > Can someone help?
> > Thanks in advanced.
> >
> > rgds,
> > Phoebe
> >
> >
>
>



Nov 20 '05 #8
Thanks again, Scott.

"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#5**************@TK2MSFTNGP10.phx.gbl...
Yes, and the only way to do that is to know what record was just edited (see my last post). Once you know what row of the grid was edited, you can use
FindControl to grab the data.
"Phoebe." <ph********@hotmail.com> wrote in message
news:ev**************@TK2MSFTNGP12.phx.gbl...
Thanks Scott.

But I need the data that pass to UpdateRecord for comparison.
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:eG**************@TK2MSFTNGP12.phx.gbl...
In the DataGrid's EditCommand event handler use the eventArgs argument to determine what row was edited (e.item?).
"Phoebe." <ph********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
> Thanks Carno.
>
> My situation is i have a edit in my datagrid and this trigger
> Sub EditRec(Byval objsrc as object, byval objargs as
> datagridcommandeventargs)
> ...
> End Sub
>
> I have a Update button which trigger
> Sub UpdateRecord(byval sender as system.object, byval e as
system.eventargs)
> ...
> End Sub
>
> I need to capture my previous record from Sub EditRec and compare
them in
> Sub UpdateRecord.
>
> Any idea on how it works?
> Thanks in advanced.
>
> rgds,
> Phoebe.
>
> "Carno C. Mercado" <on***@webgate.net.ph> wrote in message
> news:O$**************@tk2msftngp13.phx.gbl...
> > Public Class Form1
> > Private sTr as String
> > Private i as Integer
> > .
> > .
> >
> > ' Constructor
> > Public Sub New()
> > sTr = "Test"
> >
> > End Sub
> >
> > Public Sub Method1
> >
> > ' here you can see the value of sTr
> > if ( sTr = "Test ) then
> >
> > end if
> >
> > end sub
> >
> > More Functions
> >
> >
> > End Class
> >
> >
> >
> >
> > "Phoebe." <ph********@hotmail.com> wrote in message
> > news:u7**************@TK2MSFTNGP11.phx.gbl...
> > > Hi, Good Day!
> > >
> > > I need to create a variable that it's value can be carry across

within
a
> > > form.
> > >
> > > I've created some above the "web form designer generated code"
but it
> > seems
> > > not working.
> > >
> > > It reset back to nothing when i click on a button.
> > >
> > > Can someone help?
> > > Thanks in advanced.
> > >
> > > rgds,
> > > Phoebe
> > >
> > >
> >
> >
>
>



Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions>...
4
by: Andrew V. Romero | last post by:
I have been working on a function which makes it easier for me to pull variables from the URL. So far I have: <script language="JavaScript"> var variablesInUrl; var vArray = new Array(); ...
4
by: Dan Elliott | last post by:
Hello, Converting from a working C program to C++, I run into the following error: I have a header: (header.h) namespace shared{ ... struct X{ ...
2
by: Thomas Matthews | last post by:
Hi, I'm getting linking errors when I declare a variable in the global scope, but not inside a function. The declarations are the same (only the names have been changed...). class Book {...
8
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined...
17
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
10
by: Charles O'Flynn | last post by:
As a complete newcomer (2-3 days) to PHP, although not to programming in general, I have 'dived in' to start a small project to read and parse an XML data stream. I have already worked out most of...
9
by: Ed Jensen | last post by:
I'm having a vexing problem with global variables in Python. Please consider the following Python code: #! /usr/bin/env python def tiny(): bar = for tmp in foo: bar.append(tmp) foo = bar
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.