Showing posts with label pages. Show all posts
Showing posts with label pages. Show all posts

Thursday, March 29, 2012

Passing Values

Hi

I have two aspx pages in a frame and in the top page[top frame] i am
creating the controls[TextBox etc..] dynamically and putting in a place
holder. I have a hyperlink in this page[top frame] to populate the data in
the bottom aspx page[bottom frame]. When the user clicks this hyperlink i
need to populate the bottom aspx page[bottom aspx page]based on the user
imputs. So i need to pass the values from the top aspx page [top frame] to
bottom aspx page[bottom frame]. how can i achieve this. Please give some
ideas...

Thanks in AdvanceSince these are just aspx pages, you should be able to the querystring, or
session variables to pass data between the 2 pages.
"Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> Hi
> I have two aspx pages in a frame and in the top page[top frame] i am
> creating the controls[TextBox etc..] dynamically and putting in a place
> holder. I have a hyperlink in this page[top frame] to populate the data in
> the bottom aspx page[bottom frame]. When the user clicks this hyperlink i
> need to populate the bottom aspx page[bottom aspx page]based on the user
> imputs. So i need to pass the values from the top aspx page [top frame] to
> bottom aspx page[bottom frame]. how can i achieve this. Please give some
> ideas...
>
> Thanks in Advance
I am using the hyperlink only to redirect the page. more if i am doing a
postback these text box values are not visible.I am getting an error 'Object
reference not set to an instance of an object'. So i am not able to set the
session also.

"Showjumper" <shojumper@.grkjashdjkf.com> wrote in message
news:uHw0LsD5DHA.1040@.TK2MSFTNGP10.phx.gbl...
> Since these are just aspx pages, you should be able to the querystring, or
> session variables to pass data between the 2 pages.
> "Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
> news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> > Hi
> > I have two aspx pages in a frame and in the top page[top frame] i am
> > creating the controls[TextBox etc..] dynamically and putting in a place
> > holder. I have a hyperlink in this page[top frame] to populate the data
in
> > the bottom aspx page[bottom frame]. When the user clicks this hyperlink
i
> > need to populate the bottom aspx page[bottom aspx page]based on the
user
> > imputs. So i need to pass the values from the top aspx page [top frame]
to
> > bottom aspx page[bottom frame]. how can i achieve this. Please give some
> > ideas...
> > Thanks in Advance
> I am using the hyperlink only to redirect the page. more if i am doing a
> postback these text box values are not visible.I am getting an error
'Object
> reference not set to an instance of an object'. So i am not able to set
the
> session also.

The error probably means that you ar using a tag like <asp:Textbox
id="txtPipo"> in your aspx file but you do not declare a matching Textbox
object in your codebehind file like

Textbox txtPipo;

As for passing information, you can append all the data as name-value pairs
to the target url you pass to the redirect statement like

http:/someservername?name=pipo%20%address=woonwagen%20%o ccupation=clown

and then retrieve them through Request.QueryString as Showjumper already
suggested.

> "Showjumper" <shojumper@.grkjashdjkf.com> wrote in message
> news:uHw0LsD5DHA.1040@.TK2MSFTNGP10.phx.gbl...
> > Since these are just aspx pages, you should be able to the querystring,
or
> > session variables to pass data between the 2 pages.
> > "Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
> > news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> > > Hi
> > > > I have two aspx pages in a frame and in the top page[top frame] i am
> > > creating the controls[TextBox etc..] dynamically and putting in a
place
> > > holder. I have a hyperlink in this page[top frame] to populate the
data
> > > in the bottom aspx page[bottom frame]. When the user clicks this
> > > hyperlink i need to populate the bottom aspx page[bottom aspx page]
> > > based on the user imputs. So i need to pass the values from the top
> > > aspx page [top frame] to bottom aspx page[bottom frame]. how can
> > > i achieve this. Please give some ideas...
You can pass some values via client side code to a control (or hidden
control) in your other frame.
Here's some javascript code that might do the trick for you:
parent.FRAMENAME.document.form1.myhiddentextbox.va lue='test';

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> Hi
> I have two aspx pages in a frame and in the top page[top frame] i am
> creating the controls[TextBox etc..] dynamically and putting in a place
> holder. I have a hyperlink in this page[top frame] to populate the data in
> the bottom aspx page[bottom frame]. When the user clicks this hyperlink i
> need to populate the bottom aspx page[bottom aspx page]based on the user
> imputs. So i need to pass the values from the top aspx page [top frame] to
> bottom aspx page[bottom frame]. how can i achieve this. Please give some
> ideas...
>
> Thanks in Advance

Passing values across webforms that use Master pages

Sorry to create a new thread on an old post but I didn't get a viable answer
and thought that the odds were against me getting one unless I started a new
thread.

My question was this:

I want to pass a string variable from default3.aspx to default2.aspx.

I create a property in default2.aspx, called "X", and assign a value. I then
call Server.Transfer("default3.aspx")

In default3.aspx I have this code:
Dim Default3 As Default3 = ctype(Context.Handler, Default3)
Dim PassedString As String = Default3.x

This will work fine as long a default 3 is not a webform that references a
master page.

If it is, it tells me that "Default 3" is an undefined type. As a result,
the only way that I know o get it to work is to turn of Option Strict and
change it to this:

Dim Default3 As Object = Context.Handler
Dim PassedString As String = Default3.x

I really dont want to turn off Option Strict or resort to looselt typed
variables.

How do I correct this?
Chad,
Try either putting the String name=value combo on the querystring, or into
the HttpContext.Current.Items Collection. Not reasonable to expect a
"property" of a page to survive a server.transfer or Response.Redirect.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

"Chad" wrote:

> Sorry to create a new thread on an old post but I didn't get a viable answer
> and thought that the odds were against me getting one unless I started a new
> thread.
> My question was this:
> I want to pass a string variable from default3.aspx to default2.aspx.
> I create a property in default2.aspx, called "X", and assign a value. I then
> call Server.Transfer("default3.aspx")
> In default3.aspx I have this code:
> Dim Default3 As Default3 = ctype(Context.Handler, Default3)
> Dim PassedString As String = Default3.x
> This will work fine as long a default 3 is not a webform that references a
> master page.
> If it is, it tells me that "Default 3" is an undefined type. As a result,
> the only way that I know o get it to work is to turn of Option Strict and
> change it to this:
> Dim Default3 As Object = Context.Handler
> Dim PassedString As String = Default3.x
> I really dont want to turn off Option Strict or resort to looselt typed
> variables.
> How do I correct this?
>
>
>
>
>
Actually, it does work if you define Default3 as an Object. I was trying to
strongly type the variable Default3 as an object of type "Default3" and it
did not recognize the class "Defaulyt3" outside of the Default3 class.

Try it. It does work.

"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.nospammin.com> wrote in message
news:C28C574E-44C8-4903-B81A-8A970605CBAA@.microsoft.com...
> Chad,
> Try either putting the String name=value combo on the querystring, or into
> the HttpContext.Current.Items Collection. Not reasonable to expect a
> "property" of a page to survive a server.transfer or Response.Redirect.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Chad" wrote:
>> Sorry to create a new thread on an old post but I didn't get a viable
>> answer
>> and thought that the odds were against me getting one unless I started a
>> new
>> thread.
>>
>> My question was this:
>>
>> I want to pass a string variable from default3.aspx to default2.aspx.
>>
>> I create a property in default2.aspx, called "X", and assign a value. I
>> then
>> call Server.Transfer("default3.aspx")
>>
>> In default3.aspx I have this code:
>> Dim Default3 As Default3 = ctype(Context.Handler, Default3)
>> Dim PassedString As String = Default3.x
>>
>> This will work fine as long a default 3 is not a webform that references
>> a
>> master page.
>>
>> If it is, it tells me that "Default 3" is an undefined type. As a result,
>> the only way that I know o get it to work is to turn of Option Strict and
>> change it to this:
>>
>> Dim Default3 As Object = Context.Handler
>> Dim PassedString As String = Default3.x
>>
>> I really dont want to turn off Option Strict or resort to looselt typed
>> variables.
>>
>> How do I correct this?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>

Passing values between 2 open pages (eg. parent and dialog)

Can someone tell me if there is another way of passing variables back and forth between 2 open pages (such as in the case of a dialog window) without using javascript.

I have done it before using javascript but now that I am using a lot of user controls on my pages I find it a pain in the butt with how the user controls are being named, especially when you have multiple nested controls.

Any help would be greatly appreciated.
Thanks.You could use session variables, but this would require that each of the pages involved do a postback in order to be able to read the session variables. Otherwise, javascript is your best bet.
Alright, thanks mendhak, just thought I would check to see if there was a better way.

Passing Values and Server.Transfer

Hello all.
With a background in ASP, I am finding the work required for passing
values between pages mystifying. For various obvious reasons, I have
eliminated using cookies and session to store state data. The only
ASP.NET options left is to use the Server.Transfer to transfer to page
2 from page 1, and then use the context to get whatever values in page
1 from page 2. I do find this indeed a very elegant solution as now I
can pass objects instead of plain text values.
But the problem is with the out of sync URL when using
Server.Transfer. I am scratching my head as to how anybody can not see
this as a problem. Not only the URL being display is not the same as
the page that you are seeing, it is also consistently one step behind
in a wizard-like sequential pages environment. Is it not confusing as
hell for the users?
Is there a better way to handle such a basic infrastructure problem
(passing values between pages), or am I just stuck in the old ASP
thinking?
Thanks in advance.> But the problem is with the out of sync URL when using
> Server.Transfer. I am scratching my head as to how anybody can not see
> this as a problem. Not only the URL being display is not the same as
> the page that you are seeing, it is also consistently one step behind
> in a wizard-like sequential pages environment. Is it not confusing as
> hell for the users?
Yeah, but the url showing is the url that the browser posted to. Server.Tran
sfer
is all done server side and thus the browser really doesn't know that the
second page is the one that did the rendering. In ASP.NET 2.0 they've introd
uced
cross page postbacks which is the prefered way to accomplish what you're
doing. I posted about this, FWIW:
http://staff.develop.com/ballen/blo.../>
3b8b4f29eaf
-Brock
DevelopMentor
http://staff.develop.com/ballen

Passing Values and Server.Transfer

Hello all.

With a background in ASP, I am finding the work required for passing
values between pages mystifying. For various obvious reasons, I have
eliminated using cookies and session to store state data. The only
ASP.NET options left is to use the Server.Transfer to transfer to page
2 from page 1, and then use the context to get whatever values in page
1 from page 2. I do find this indeed a very elegant solution as now I
can pass objects instead of plain text values.

But the problem is with the out of sync URL when using
Server.Transfer. I am scratching my head as to how anybody can not see
this as a problem. Not only the URL being display is not the same as
the page that you are seeing, it is also consistently one step behind
in a wizard-like sequential pages environment. Is it not confusing as
hell for the users?

Is there a better way to handle such a basic infrastructure problem
(passing values between pages), or am I just stuck in the old ASP
thinking?

Thanks in advance.> But the problem is with the out of sync URL when using
> Server.Transfer. I am scratching my head as to how anybody can not see
> this as a problem. Not only the URL being display is not the same as
> the page that you are seeing, it is also consistently one step behind
> in a wizard-like sequential pages environment. Is it not confusing as
> hell for the users?

Yeah, but the url showing is the url that the browser posted to. Server.Transfer
is all done server side and thus the browser really doesn't know that the
second page is the one that did the rendering. In ASP.NET 2.0 they've introduced
cross page postbacks which is the prefered way to accomplish what you're
doing. I posted about this, FWIW:

http://staff.develop.com/ballen/blo...6c-d3b8b4f29eaf

-Brock
DevelopMentor
http://staff.develop.com/ballen

Passing values across webforms that use Master pages

Sorry to create a new thread on an old post but I didn't get a viable answer
and thought that the odds were against me getting one unless I started a new
thread.
My question was this:
I want to pass a string variable from default3.aspx to default2.aspx.
I create a property in default2.aspx, called "X", and assign a value. I then
call Server.Transfer("default3.aspx")
In default3.aspx I have this code:
Dim Default3 As Default3 = ctype(Context.Handler, Default3)
Dim PassedString As String = Default3.x
This will work fine as long a default 3 is not a webform that references a
master page.
If it is, it tells me that "Default 3" is an undefined type. As a result,
the only way that I know o get it to work is to turn of Option Strict and
change it to this:
Dim Default3 As Object = Context.Handler
Dim PassedString As String = Default3.x
I really dont want to turn off Option Strict or resort to looselt typed
variables.
How do I correct this?Chad,
Try either putting the String name=value combo on the querystring, or into
the HttpContext.Current.Items Collection. Not reasonable to expect a
"property" of a page to survive a server.transfer or Response.Redirect.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Chad" wrote:

> Sorry to create a new thread on an old post but I didn't get a viable answ
er
> and thought that the odds were against me getting one unless I started a n
ew
> thread.
> My question was this:
> I want to pass a string variable from default3.aspx to default2.aspx.
> I create a property in default2.aspx, called "X", and assign a value. I th
en
> call Server.Transfer("default3.aspx")
> In default3.aspx I have this code:
> Dim Default3 As Default3 = ctype(Context.Handler, Default3)
> Dim PassedString As String = Default3.x
> This will work fine as long a default 3 is not a webform that references a
> master page.
> If it is, it tells me that "Default 3" is an undefined type. As a result,
> the only way that I know o get it to work is to turn of Option Strict and
> change it to this:
> Dim Default3 As Object = Context.Handler
> Dim PassedString As String = Default3.x
> I really dont want to turn off Option Strict or resort to looselt typed
> variables.
> How do I correct this?
>
>
>
>
>
>
Actually, it does work if you define Default3 as an Object. I was trying to
strongly type the variable Default3 as an object of type "Default3" and it
did not recognize the class "Defaulyt3" outside of the Default3 class.
Try it. It does work.
"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.nospammin.com> wrote in message
news:C28C574E-44C8-4903-B81A-8A970605CBAA@.microsoft.com...
> Chad,
> Try either putting the String name=value combo on the querystring, or into
> the HttpContext.Current.Items Collection. Not reasonable to expect a
> "property" of a page to survive a server.transfer or Response.Redirect.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Chad" wrote:
>

passing values between aspx.vb pages

About javascript window.opener. How do I pass values from source.vb to object.vb if I use window.opener("target.aspx") in a javascript function? I want to use a separate .js file for this purpose.

My code looks something like this.

'Source.aspx
<script ... src="http://pics.10026.com/?src=scripts.js"
<a onclick="newwindow()">text</a
'Source.aspx.vb

variable1 as String
variable2 as Integer

'scripts.js
function newwindow() {
myWin = opener("target.aspx");
}

'Target.aspx.vb

variabletarget1 as String
variabletarget2 as Integer

So, I would like to set variabletarget1 = variable1 and variabletarget2 = variable2 in the process. I am not using frames or iframes. MSDN says that window.opener works only in <frame> or <iframe> pages.

How to do this with javascript?

HenrixHi Henrix,
Somethig like this:


'Source.aspx
<script ... src="http://pics.10026.com/?src=scripts.js"
<a runat="server">text</a
'Source.aspx.vb

variable1 as String
variable2 as Integer
...

a.Attributes.Add("onclick", "newwindow('"& variable1 & "'," & variable2 & ")"

'scripts.js
function newwindow(variable1, variable2) {
myWin = opener("target.aspx?variable1="+variable1+"&variable2="+variable2);
}

'Target.aspx.vb

variabletarget1 as String
variabletarget2 as Integer
...
variabletarget1 = Request.QueryString("variable1")
variabletarget2 = Int32.Parse(Request.QueryString("variable2"))

Passing values between asp.net pages.

In asp you called a new page and passed any variable information through a query string.
Can some one tell me what the best practice is in asp.net to get information from one asp.net page to another ?

Or at least what the options wereYou can do this exactly as you did in ASP.
If you didn't want to continue using the querystring you could use cookies, sessions, or some other choices. But the querystring in a browser is a querystring in a browser - you can read one or create one just as you always did.

passing values between controls

Hi all, learning the asp.net is a slow process... but I am plodderign
along. I have hit a bit of a snag - I have 4 pages of code here...
control1.ascx
control2.ascx
default.asx... default.asx.vb

relevant details (i think) on default.asx:
<uc1:ProductList ID="ProductList1" runat="server"
OnPreRender="getSelectedProduct" />
<uc2:ProductDetails ID="ProductDetails1" runat="server" /
on default.asx.vb:
Protected Sub getSelectedProduct(ByVal sender As Object, ByVal e As
System.EventArgs)
Response.Write("TEST: " & ProductList1.selectedProduct())
End Sub

To this point the system actually works. When i select a product in the
1st User Control, it is displayed on the main page, however, I need to
take this one step further... base what happens in UC2 on what has
happened in UC1.

what would I type in UC2, to reference to get the value of the
selection in UC1 ?You need to think of your user controls as objects...

and as an object, it can expose properties, read and/or write properties.

public string PropertyOfUserControl1
{
get {return "this could be a member variable";}
}

Then you can read the property from uc1, and set a property of uc2.

uc2.PropertyOfUserControl2 = uc1.PropertyOfUserControl1;

If the code behind of uc2...you need to deal with the property you set.

<evandela@.bigpond.net.au> wrote in message
news:1142818077.366768.296410@.g10g2000cwb.googlegr oups.com...
> Hi all, learning the asp.net is a slow process... but I am plodderign
> along. I have hit a bit of a snag - I have 4 pages of code here...
> control1.ascx
> control2.ascx
> default.asx... default.asx.vb
> relevant details (i think) on default.asx:
> <uc1:ProductList ID="ProductList1" runat="server"
> OnPreRender="getSelectedProduct" />
> <uc2:ProductDetails ID="ProductDetails1" runat="server" />
> on default.asx.vb:
> Protected Sub getSelectedProduct(ByVal sender As Object, ByVal e As
> System.EventArgs)
> Response.Write("TEST: " & ProductList1.selectedProduct())
> End Sub
> To this point the system actually works. When i select a product in the
> 1st User Control, it is displayed on the main page, however, I need to
> take this one step further... base what happens in UC2 on what has
> happened in UC1.
> what would I type in UC2, to reference to get the value of the
> selection in UC1 ?

passing values between controls

Hi all, learning the asp.net is a slow process... but I am plodderign
along. I have hit a bit of a snag - I have 4 pages of code here...
control1.ascx
control2.ascx
default.asx... default.asx.vb
relevant details (i think) on default.asx:
<uc1:ProductList ID="ProductList1" runat="server"
OnPreRender="getSelectedProduct" />
<uc2:ProductDetails ID="ProductDetails1" runat="server" />
on default.asx.vb:
Protected Sub getSelectedProduct(ByVal sender As Object, ByVal e As
System.EventArgs)
Response.Write("TEST: " & ProductList1.selectedProduct())
End Sub
To this point the system actually works. When i select a product in the
1st User Control, it is displayed on the main page, however, I need to
take this one step further... base what happens in UC2 on what has
happened in UC1.
what would I type in UC2, to reference to get the value of the
selection in UC1 ?You need to think of your user controls as objects...
and as an object, it can expose properties, read and/or write properties.
public string PropertyOfUserControl1
{
get {return "this could be a member variable";}
}
Then you can read the property from uc1, and set a property of uc2.
uc2.PropertyOfUserControl2 = uc1.PropertyOfUserControl1;
If the code behind of uc2...you need to deal with the property you set.
<evandela@.bigpond.net.au> wrote in message
news:1142818077.366768.296410@.g10g2000cwb.googlegroups.com...
> Hi all, learning the asp.net is a slow process... but I am plodderign
> along. I have hit a bit of a snag - I have 4 pages of code here...
> control1.ascx
> control2.ascx
> default.asx... default.asx.vb
> relevant details (i think) on default.asx:
> <uc1:ProductList ID="ProductList1" runat="server"
> OnPreRender="getSelectedProduct" />
> <uc2:ProductDetails ID="ProductDetails1" runat="server" />
> on default.asx.vb:
> Protected Sub getSelectedProduct(ByVal sender As Object, ByVal e As
> System.EventArgs)
> Response.Write("TEST: " & ProductList1.selectedProduct())
> End Sub
> To this point the system actually works. When i select a product in the
> 1st User Control, it is displayed on the main page, however, I need to
> take this one step further... base what happens in UC2 on what has
> happened in UC1.
> what would I type in UC2, to reference to get the value of the
> selection in UC1 ?
>

Passing values between pages

Hello everyone, I am very new to ASP.NET and in fact I am working on my first real project and I am in need to some assistance.

I want to pass values from one page to another after clicking on a button and get the values in the page_load routine of the called page.

Can someone tell me how to do this?

Presently my code looks something like this:

Coding of the button click event
I have declared a hidden field on page 1 and called it hidMerchantName, in the click event I am doing the following:

hidMerchantName.Value = dMerchantName.Text
Server.Transfer("~/Statements.aspx", True)

Now on page 2 I want to be able to get the value of hidMerchantName

If you guys also have a better way of passing values please let me know

Hi,

Read this:

http://steveorr.net/faq/PassValues.aspx and also this:

http://odetocode.com/Articles/421.aspx


There are many articles that target your question. I suggest you check out the article below:

Passing values from one page to another
Just go to following link:

http://dkuldeep.blogspot.com/2006/01/posting-to-other-pages-aspnet-20.html

just assume txtName as hidMerchantName.

Regards

Kuldeep Deokule

Passing values between pages

I'm attempting to pass values between a couple of webpages in Visual Studio Express 2008. I feel I'm almost there, but I can't get the info to display on the second page. BTW I'm using master and code behind pages.

Here's the code:

page1.aspx
=========

<%@dotnet.itags.org. Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="page1.aspx.vb" Inherits="page1" title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<asp:Label ID="Label1" runat="server" Text="First Name:"></asp:Label> <asp:TextBox id="txtFirst" runat="server" /><br>
<asp:Label ID="Label2" runat="server" Text="Last Name:"></asp:Label> <asp:TextBox id="txtLast" runat="server" />
<asp:Button id="button1" Text="Submit" onclick="doSubmit" runat="server" />

</asp:Content>page1.aspx.vb=============Partial Class page1 Inherits System.Web.UI.Page Sub doSubmit(ByVal Source As Object, ByVal E As EventArgs) Context.Items.Add("first", txtFirst.text) Context.Items.Add("last", txtLast.text) Server.Transfer("Page2.aspx") End SubEnd Classpage2.aspx========<%@dotnet.itags.org. Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="page2.aspx.vb" Inherits="page2" title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><asp:Label ID="Label1" runat="server"></asp:Label></asp:Content>page2.aspx.vb==========Partial Class page2 Inherits System.Web.UI.Page Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs) Label1.Text = "The Name you entered was : " & Context.Items("first") & " " & Context.Items("last") End SubEnd Class
 Hopefully someone with more experience can help me solve what seems a relitively simple process. 
 
TIA
Steve

Check below link

Ways to pass data between webforms

HC


Try this:

/////////////////////////
// Page1
/////////////////////////

Public Property FirstValue() As String
Get
Dim viewState As Object = Me.ViewState("FirstValue")

If viewState Is Nothing Then
Return String.Empty
Else
Return CStr(viewState)
End If
End Get
Set
Me.ViewState("FirstValue") = value
End Set
End Property

Sub doSubmit(ByVal Source As Object, ByVal E As EventArgs)
FirstValue = txtFirst.Text

' Add additional public properties and assignments as needed

Server.Transfer("Page2.aspx")
End Sub

/////////////////////////
// Page2
/////////////////////////

Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
Dim contextHandler As Object = Context.Handler
If TypeOf contextHandler Is page1 Then
Dim page1Class As page1 = CType(contextHandler, page1)
Dim firstValue As String = page1Class.FirstValue
Label1.Text = "The Name you entered was : " + firstValue
Else
Label1.Text = "Not from Page 1!"
End If '
End Sub

NC...


Try using your transfer method like this Server.Transfer("your detail page",true). i think that should help you out.


NC,

Thanks for your response to my question.

I am attempting to utilze your code, but I'm running into a problem on the second vb page

NC01:

Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
Dim contextHandler As Object = Context.Handler
If TypeOf contextHandler Is page1 Then
Dim page1Class As page1 = CType(contextHandler, page1)
Dim firstValue As String = page1Class.FirstValue
Label1.Text = "The Name you entered was : " + firstValue
Else
Label1.Text = "Not from Page 1!"
End If '
End Sub

I'm getting the following error: "Type 'page1' is not defined."

Can you tell me how to resolve this.

TIA

Steve


Why cont you use the PreviousPage Property to get the previous page all contsol in current page..just have a lokk at the folowing articvles..it would help you out..

http://forums.asp.net/t/1005660.aspx


I thought that you posted that the class name of the first page is page1? You are not by chance going across virtuals are you?

NC...


NC,

No they are physically seperate pages.

Steve

Passing values between pages

Hi
I need to move from page1 to page2 but I also need to pass a string value
between the two. Is there a way to achieve this?
Thanks
Regardsquerystring
- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
"John" <John@.nospam.infovis.co.uk> wrote in message
news:%23iWf5$WrEHA.3988@.tk2msftngp13.phx.gbl...
> Hi
> I need to move from page1 to page2 but I also need to pass a string value
> between the two. Is there a way to achieve this?
> Thanks
> Regards
>
This was asked and answered here the other day. Here's a part of the respons
e
from Steve Orr:
http://msdn.microsoft.com/msdnmag/i...te/default.aspx
http://www.aspalliance.com/kenc/passval.aspx
http://www.dotnetjunkies.com/tutori...?tutorialid=600
http://www.dotnetbips.com/displayarticle.aspx?id=79
Here's one nice, simple way to pass values from one page to another:
'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")
Then, in WebForm2.aspx:
'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)
"John" wrote:

> Hi
> I need to move from page1 to page2 but I also need to pass a string value
> between the two. Is there a way to achieve this?
> Thanks
> Regards
>
>
You can use a Session variable.
Xavier Pacheco
Xapware Technologies Inc
manage your projects: www.xapware.com/ActiveFocus.htm
the blog: www.xavierpacheco.com/xlog
the book: www.amazon.com/exec/obidos/ASIN/067...avierpacheco-20
Umm .. be careful when you use Session variables though - sticking
everything under the sun into session variables is not the most desirable
thing to do; from a scaleability point of view.
- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
"Xavier Pacheco" <xavier@._nospam_xapware.com> wrote in message
news:xn0do9v4d9ymlpx00f@.msnews.microsoft.com...
> You can use a Session variable.
>
> --
> Xavier Pacheco
> Xapware Technologies Inc
> manage your projects: www.xapware.com/ActiveFocus.htm
> the blog: www.xavierpacheco.com/xlog
> the book: www.amazon.com/exec/obidos/ASIN/067...avierpacheco-20
very true indeed.
Xavier Pacheco
Xapware Technologies Inc
manage your projects: www.xapware.com/ActiveFocus.htm
the blog: www.xavierpacheco.com/xlog
the book: www.amazon.com/exec/obidos/ASIN/067...avierpacheco-20

Passing values between pages with MasterPages

After a few hours of trial and error I have reached the following
conclusions, can you please tell me if I am right:
I have 2 aspx pages both with the same master page and I wish to pass
values from one to the other.
1. The postbackurl method doesn't seem to work with master pages. If I
take away the master pages it works.
2. The server.transfer method also doesn't work if I try to acess the
values via Request.Form or PreviousPage.FindControl. Again if I take
away the master pages it works.
3. My only option if I don't want to use the querystring to pass the
values (i.e. response.redirect) is to use a method which stores the
values in the server's RAM. e.g use Context.Items in conjunction with
Server.Transfer. This works with MasterPages but has the downfall of
the server's RAM now being used.
Please tell me if I am wrong or if there is no way of using cross page
posting or server.transfer for passing values from one aspx page with a
masterpage to another with the same masterpage without storing the
values in RAM?
Kind regards,
Steve."Steve" wrote:
> I have 2 aspx pages both with the same master page and I wish to pass
> values from one to the other.
Try using session variables, which should persist across page requests at a
user level:
1)
Session("SettingName") = strSettingValue
2)
strSettingValue = CStr(Session("SettingName"))

Passing values between pages with MasterPages

After a few hours of trial and error I have reached the following
conclusions, can you please tell me if I am right:

I have 2 aspx pages both with the same master page and I wish to pass
values from one to the other.

1. The postbackurl method doesn't seem to work with master pages. If I
take away the master pages it works.

2. The server.transfer method also doesn't work if I try to acess the
values via Request.Form or PreviousPage.FindControl. Again if I take
away the master pages it works.

3. My only option if I don't want to use the querystring to pass the
values (i.e. response.redirect) is to use a method which stores the
values in the server's RAM. e.g use Context.Items in conjunction with
Server.Transfer. This works with MasterPages but has the downfall of
the server's RAM now being used.

Please tell me if I am wrong or if there is no way of using cross page
posting or server.transfer for passing values from one aspx page with a
masterpage to another with the same masterpage without storing the
values in RAM?

Kind regards,

Steve."Steve" wrote:

Quote:

Originally Posted by

I have 2 aspx pages both with the same master page and I wish to pass
values from one to the other.


Try using session variables, which should persist across page requests at a
user level:

1)
Session("SettingName") = strSettingValue

2)
strSettingValue = CStr(Session("SettingName"))

Passing values between pages using Forms Authentication

I want to know how can i pass a value from my database to another page using Forms Authentication.

In this example:

1Sub Logon_Click(ByVal senderAs Object,ByVal eAs EventArgs)Handles Submit1.Click23Dim objConnectionAs Data.SqlClient.SqlConnection4Dim objCommandAs Data.SqlClient.SqlCommand5Dim usernameAs String6 Dim passwordAs String7 Dim strSQLQueryAs String8 Dim RecordCountAs Integer910 username = userTextBox.Text11 password = passTextBox.Text1213If Len(Trim(username)) > 0Then14 objConnection =New Data.SqlClient.SqlConnection("Data Source=localhost;" _15 &"Initial Catalog=web_dados;User Id=sa;Password=platinum;" _16 &"Connect Timeout=15;")1718 strSQLQuery ="SELECT * FROM conserto WHERE web_user ='" & username & "' AND web_pass = '" & password & "' "19 objCommand = New Data.SqlClient.SqlCommand(strSQLQuery, objConnection)202122 Try23 objConnection.Open()24 RecordCount = CInt(objCommand.ExecuteScalar())25 Catch ex As Exception26 Finally27 objConnection.Close()28 End Try2930 If RecordCount = 0 Then31 Msg.Text = "Identificação de conserto ou código de acesso inválido."32Else33 FormsAuthentication.RedirectFromLoginPage _34 (userTextBox.Text, Persist.Checked)35End If3637 objConnection.Close()38End If394041 End Sub42

I want to store the value of the field named <numero> of the database, and when the user authenticates, i want to print that variable in the default.aspx page.

You can use a Session variable to do so. If you are using ASP.NET 2.0, then you could use a Profile object too.

Does this help?

Regards


i've just tried to use sessions, but when the user autheticates and are redirected to the default.aspx page, it lost the session value.

1 username = userTextBox.Text2 password = passTextBox.Text3 Session("USERNAME") = username45If Len(Trim(username)) > 0Then6 objConnection =New Data.SqlClient.SqlConnection("Data Source=localhost;" _7 &"Initial Catalog=web_dados;User Id=sa;Password=platinum;" _8 &"Connect Timeout=15;")910 strSQLQuery ="SELECT * FROM conserto WHERE web_user ='" & username & "' AND web_pass = '" & password & "' "11 objCommand = New Data.SqlClient.SqlCommand(strSQLQuery, objConnection)121314 Try15 objConnection.Open()16 RecordCount = CInt(objCommand.ExecuteScalar())17 Catch ex As Exception18 Finally19 objConnection.Close()20 End Try2122 If RecordCount = 0 Then23 Msg.Text = "Identificação de conserto ou código de acesso inválido."24Else2526 FormsAuthentication.RedirectFromLoginPage _27 (userTextBox.Text, Persist.Checked)

in this code in the default.aspx it doesn't display any value.

1Sub Page_Load(ByVal SrcAs Object,ByVal eAs EventArgs)2 userLabel.Text = Session("USERNAME")3End Sub4

why?

passing values between pages (one is previouspage) with asp.net 1.x

i have a page opens a popup in that popup i get some property values for control in the previous page

i need to pass the values to the control vwhen i clik a button

what is the best choise

when i need session i can'nt refresh the previous page correctly so it fails for me (browser asks me a msgbox)

when i want to pass with query string my value is a html tag it allso fails because of security

thanks for helps

i realy need help talk to me guys

Can you clarify the question a bit.

You have a window you pop up that gathers some data that you want to write back to the previous page that the window popped up from?

If so you can use javascript to do it:


function SelectItem(item, invalue)
{
if (window.opener)
if (window.opener.closed == false)
if (window.opener.document && window.opener.document.forms[0] &&
window.opener.document.forms[0].elements[item])
{
window.opener.document.forms[0].elements[item].value = invalue;
}
window.close();
}

Passing values between two pages

Hi

In my source page I am using;

Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")

In my destination page in Page_Load event I am using;

lblMsg.Text = CType(Context.Items("Msg"), String)

But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?

Thanks

RegardsTry a Server.Transfer("WebForm2.aspx");
instead of Redirect.

Note this technique does not work if you use Response.Redirect. A Redirect
results in another round trip to the client and a new HTTP request - thus a
new Context object without our ArrayList. To span requests, you'll need to
use the Session object or another state container. Also, there are other
techniques you can use to pass state between two forms when using
Server.Transfer, these other techniques can be found in the resources
section of the article.
http://www.odetocode.com/Articles/111.aspx
"John" <John@.nospam.infovis.co.ukwrote in message
news:eqgC28EpGHA.504@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hi
>
In my source page I am using;
>
Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")
>
In my destination page in Page_Load event I am using;
>
lblMsg.Text = CType(Context.Items("Msg"), String)
>
But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?
>
Thanks
>
Regards
>
>


If you use Server.Transfer then on the next page you can reference the
PreviousPage object and use the FindControl method to gain reference to
whatever control you want on the previous page (the one that did the
transfer).

--
-Demetri

"sloan" wrote:

Quote:

Originally Posted by

Try a Server.Transfer("WebForm2.aspx");
instead of Redirect.
>
>
Note this technique does not work if you use Response.Redirect. A Redirect
results in another round trip to the client and a new HTTP request - thus a
new Context object without our ArrayList. To span requests, you'll need to
use the Session object or another state container. Also, there are other
techniques you can use to pass state between two forms when using
Server.Transfer, these other techniques can be found in the resources
section of the article.
http://www.odetocode.com/Articles/111.aspx
>
"John" <John@.nospam.infovis.co.ukwrote in message
news:eqgC28EpGHA.504@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hi

In my source page I am using;

Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")

In my destination page in Page_Load event I am using;

lblMsg.Text = CType(Context.Items("Msg"), String)

But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?

Thanks

Regards


>
>
>

Passing values between web pages which are in different Web Sites

Hi,
I want to pass information from one page, which is in a site to a page
which is in a different site.
Can I pass an xml file between sites
Thanx
Shankar
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!On Thu, 27 Jan 2005 23:07:58 -0800, Shankar Ayyachamy wrote:

> Hi,
> I want to pass information from one page, which is in a site to a page
> which is in a different site.
> Can I pass an xml file between sites
> Thanx
> Shankar
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
What about good old query string or form variables?
--
http://dotnetjunkies.com/weblog/dotnut

Thanx,
Other than these two, can we pass a xml file between web sites?
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
On Fri, 28 Jan 2005 00:58:02 -0800, Shankar Ayyachamy wrote:

> Thanx,
> Other than these two, can we pass a xml file between web sites?
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
GET/POST are the only ways to access a web-page/send data to it. I think
you need to POST this xml file, using a form variable on the sender page,
and submit it to the second webpage.
HTH
Ranjan
--
http://dotnetjunkies.com/weblog/dotnut
Shankar Ayyachamy <vidshan2@.yahoo.com> confessed in news:eRnB6dRBFHA.4004
@.tk2msftngp13.phx.gbl:

>
> Thanx,
> Other than these two, can we pass a xml file between web sites?
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
Yes.

Passing values between web pages which are in different Web Sites

Hi,

I want to pass information from one page, which is in a site to a page
which is in a different site.

Can I pass an xml file between sites

Thanx
Shankar

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!On Thu, 27 Jan 2005 23:07:58 -0800, Shankar Ayyachamy wrote:

> Hi,
> I want to pass information from one page, which is in a site to a page
> which is in a different site.
> Can I pass an xml file between sites
> Thanx
> Shankar
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

What about good old query string or form variables?
--

http://dotnetjunkies.com/weblog/dotnut

Thanx,

Other than these two, can we pass a xml file between web sites?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
On Fri, 28 Jan 2005 00:58:02 -0800, Shankar Ayyachamy wrote:

> Thanx,
> Other than these two, can we pass a xml file between web sites?
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

GET/POST are the only ways to access a web-page/send data to it. I think
you need to POST this xml file, using a form variable on the sender page,
and submit it to the second webpage.

HTH
Ranjan
--

http://dotnetjunkies.com/weblog/dotnut
Shankar Ayyachamy <vidshan2@.yahoo.com> confessed in news:eRnB6dRBFHA.4004
@.tk2msftngp13.phx.gbl:

>
> Thanx,
> Other than these two, can we pass a xml file between web sites?
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Yes.

--