How to refer to a variable on another webform
Hi, I have a Webform1 with a public variable that is assigned a value before
my Webform2 is displayed. In the Page_Load procedure of Webform2 I want to
evaluate the value of the variable of Webform1.
Code on Webform1
Public MyVar1 As Integer
Private Sub Button1_ServerC lick(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.ServerC lick
MyVar1 = 1
Server.Transfer ("Webform2.aspx ")
End Sub
Code on Webform2
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim Myvar2 As Integer
Myvar2 = (Myvar1 from Webform1... Any Ideas?)
End Sub
T I Rislaa 3 1551
You can't. Once the webform1 finishes execution, it ceases to exist.
You will have to store the value in session or pass it in the query string,
or place it elsewhere where both forms can access to it.
"Tor Inge Rislaa" <to************ *@rislaa.no> wrote in message
news:e5******** ******@TK2MSFTN GP12.phx.gbl... How to refer to a variable on another webform
Hi, I have a Webform1 with a public variable that is assigned a value
before my Webform2 is displayed. In the Page_Load procedure of Webform2 I want to evaluate the value of the variable of Webform1.
Code on Webform1
Public MyVar1 As Integer
Private Sub Button1_ServerC lick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.ServerC lick
MyVar1 = 1 Server.Transfer ("Webform2.aspx ")
End Sub
Code on Webform2
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Dim Myvar2 As Integer Myvar2 = (Myvar1 from Webform1... Any Ideas?)
End Sub
T I Rislaa
Open the Visual Studio.NET help....and type in the
following in the address bar.....
ms-
help://MS.VSCC/MS.MSDNVS/vbcon/html/vbtskPassingVal uesBetwe
enWebFormsPages .htm
It describes how to pass values in between web forms and
of course you can always use query strings too.
Thanks,
Tap -----Original Message----- How to refer to a variable on another webform
Hi, I have a Webform1 with a public variable that is
assigned a value beforemy Webform2 is displayed. In the Page_Load procedure of
Webform2 I want toevaluate the value of the variable of Webform1.
Code on Webform1
Public MyVar1 As Integer
Private Sub Button1_ServerC lick(ByVal sender As
System.Object, ByVal e AsSystem.EventAr gs) Handles Button1.ServerC lick
MyVar1 = 1 Server.Transfer ("Webform2.aspx ")
End Sub
Code on Webform2
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e AsSystem.EventAr gs) Handles MyBase.Load
Dim Myvar2 As Integer Myvar2 = (Myvar1 from Webform1... Any Ideas?)
End Sub
T I Rislaa .
That's not correct.
You can use server.transfer as your code is beginning to. The next step is
to recreate the first page on the second. You will need to do a CType on the
context object that is passed using server.transfer .
Dim Page1 As Page1 = CType(Context, Page1)
The important thing is that if you can arrive at a page2 from more pages
than page1 this code will error out if you try to make say, page3, into
page1.
I have some sample code in the code library on my website, www.aboutfortunate.com for determining which page a context object came
from. Just search for: "get page name".
I hope this helps.
--
S. Justin Gengo, MCP
Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Marina" <zl*******@nosp am.hotmail.com> wrote in message
news:ee******** ******@TK2MSFTN GP11.phx.gbl... You can't. Once the webform1 finishes execution, it ceases to exist.
You will have to store the value in session or pass it in the query
string, or place it elsewhere where both forms can access to it.
"Tor Inge Rislaa" <to************ *@rislaa.no> wrote in message news:e5******** ******@TK2MSFTN GP12.phx.gbl... How to refer to a variable on another webform
Hi, I have a Webform1 with a public variable that is assigned a value before my Webform2 is displayed. In the Page_Load procedure of Webform2 I want
to evaluate the value of the variable of Webform1.
Code on Webform1
Public MyVar1 As Integer
Private Sub Button1_ServerC lick(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.ServerC lick
MyVar1 = 1 Server.Transfer ("Webform2.aspx ")
End Sub
Code on Webform2
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Dim Myvar2 As Integer Myvar2 = (Myvar1 from Webform1... Any Ideas?)
End Sub
T I Rislaa
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew |
last post by:
Hi,
Until now, I have used a single webform for my web app,
and everything's been OK. Now, I've decided to create a
main menu webform. So, I've got two webforms. Using
Visual Studio .NET (with C#), I've made the menu webform
the "start page", but I am unable to change to the other
webform. I plan to have several webforms, all of which
will be activated from the main menu webform by clicking
on a button.
|
by: Epson Barnett |
last post by:
Hi,
I'm new to C# and I'd like to be able to reference a field of an
object using a variable instead of literal text.
In the PHP scripting language, you can create a variable:
$var = "name";
and another variable:
$name = "Epson";
Then you can refer to $name, or $$var. They will equal the same thing.
|
by: dave |
last post by:
I have a webform with many checkboxes on it. I want the
user to be able click on a button and the page be posted
to another webform so that I can capture which checkboxes
were selected.
For all other buttons on the page i want the page to be
reposted back to the same webform.
What is the best method to accomplish the above?
thx
|
by: news_server.nc.rr.com |
last post by:
How do i perform a databind on a web user control within a repeater or
rather
how can I access the datasource that is already bound? I have a web user
control that displays a table of values (the profile of a piece of
equipment)
from SQLServer. I've used a repeater on the webform since a query (i.e. by
address) against the DB may return multiple machine profiles and I want to
use the repeater to display as many machine profiles as are...
|
by: Antoine |
last post by:
I have a pretty quickish question about ASPX with codebehind. I have done an
exhaustive search of the web so no go there. I was hoping to reach out for
some help here.
Anyway, I have a really nicely working javascript replace going on with
multiple data items databinded to an aspx web form so that I am
theoretically much simplifying the data sent back from the codebehind
(literally values such as 1,2,3 that can define which webpage to go...
| |
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 InOutHost.TabShow("pagBoard"), the
reference to InOutHost is not resolved. Thanks, Dean S
Partial Public Class InOutHost
Inherits System.Web.UI.Page
|
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, but if I window.open another instance of that webform, that variable
should be independant even if the name is the same.
I've declared that var as Public shared, but I realize now that that
variable is modifiable from all the webforms, and even...
|
by: Luqman |
last post by:
How can I open another WebForm in ASP.Net / VS 2005 without closing the
Current Webform.
I tried using Server.Transfer("Form2.Aspx",True) on Button_Click of Form1
but it close the current web form and opened the form2, and when I click on
the button on form2 which had Server.Transfer("Form1.Aspx"), the form1
initialized and all the values of form1 controls set to blank, any idea
please ?
My Form1 has some textboxes and a search...
|
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 on the second webform? I have a
base webform class that both webforms inherit
webform1 : BaseWebclass
webform2 :BaseWebclass
so I do not think I can just inherit webform1 in webform2
thanks
--
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |