Showing posts with label variables. Show all posts
Showing posts with label variables. Show all posts

Thursday, March 29, 2012

Passing Values

I know that I can create session variables and pass those values from one
screen to another, but is there not a way to makes variables from one scree
n available to another screen other then session variables? Is there not a
way to create properties in the one screen and then pass some sort of
reference to the screen you are calling?

Can you point me to an example or an article on how to use?

Thanks in advance for your assistance!!!!!!!!Passing Values from Aspx to Aspx

Although ASP.NET usually submits data to the current page for processing,
there are times when you need to pass values from the controls on one page
to controls or routines on another ASP.NET page.
This is a cookbook style tutorial that shows you how to pass from one page
to another. For a deeper explanation, see the Microsoft Help file references
at the bottom of the page.

http://authors.aspalliance.com/kenc/passval.aspx

"Jim Heavey" <JimHeavey@.nospam.com> wrote in message
news:Xns948861B2BA553JimHeaveyhotmailcom@.207.46.24 8.16...
>I know that I can create session variables and pass those values from one
> screen to another, but is there not a way to makes variables from one
> scree
> n available to another screen other then session variables? Is there not
> a
> way to create properties in the one screen and then pass some sort of
> reference to the screen you are calling?
> Can you point me to an example or an article on how to use?
> Thanks in advance for your assistance!!!!!!!!
someone asked exactly the same questions like 10 posts before you so check there

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 from labels to text boxes via session variables

I'm passing label values from one page to text boxes in another page for user update. I'm using session variables, but I have been unable to display the passed values in the receiving text boxes. I'm not sure if the syntax is wrong or if the constructs are inappropriate. I'm new and need help.

<code>
SENDING PAGE:

<%@dotnet.itags.org. Page Language="vb" %>
<script runat="server"
Sub doSubmit(Source as Object, E as EventArgs)
Context.Items.Add("first", txtFirst.text)
Context.Items.Add("last", txtLast.text)
Server.Transfer("3.aspx")
End Sub

</script>
<html
<head>
<title>1.aspx</title>
</head
<body
<form id="form1" runat="server">
First Name: <asp:TextBox id="txtFirst" runat="server" /><br>
Last Name: <asp:TextBox id="txtLast" runat="server" />
<asp:Button id="button1" Text="Submit" onclick="doSubmit" runat="server" />
</Form>
</body>
</html
RECEIVING PAGE:

<%@dotnet.itags.org. Page Language="vb" %>
<script runat="server"
Sub Page_Load(Source as Object, E as EventArgs)

label1.text = "The Name you entered was : " & Context.Items("first") & " " & _
Context.Items("last")
textbox1.text = Context.Items("First")
textbox2.text = Context.Items("Last")

End Sub

</script>
<html>
<head>
<title>Second Page</title>
<asp:Label ID="label1" runat="server" />
</head>
<body>
<form name="Form1" runat="server">
<asp:TextBox id="textBox1" Text='<%# "textbox1" %>' runat="server"></asp:TextBox>
<asp:TextBox id="textBox2" Text='<%# "textbox2" %>' runat="server"></asp:TextBox>
</form>
</body>
</htmlIn the recieving pae's load event you're setting the value of the textbox so you don't need to bind the text box's value to itself (so just leave out the "Text=' etc." attribute).

Also, the items collection is case sensitive. You're adding items as "first" and "last" but you're trying to retrieve values from "First" and "Last". Choose a case and stick with it and the problem is resolved.
you made my day Chapel21. thanx for the prompt response and the explanation given, it makes a bit clearer what each line of code does.

sometimes I think I should've studied CGI scripting 5 years ago, when i had time to invest. by now, ASP .NET should've been simpler to understand and use, or may be not.. thanx again,

Monday, March 26, 2012

Passing variable between asp login page and the redirected page

Hi All

I have an asp.net 2.0 web with a standard login control

I want to pass some extra variables to the redirected page after the successful login

I just can't get it to work. help much appreciated

--------------------------
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate

Context.Items.Clear()

Context.Items.Add("UserNamevalue", Me.Login1.UserName)

Context.Items.Add("mydbkeyvalue", 2)

FormsAuthentication.RedirectFromLoginPage("steve", False)

Server.Transfer("~/memberpages/demos.aspx", True)

End If

Catch ex As Exception

Response.Write(ex.Message)

End Try

End Sub

---------------------------------------

In a link button onclick event on the demos.aspx

Me.lblsamupdate.Text = "Context " & Context.Items("UserNamevalue").ToString

I get error 'Object reference not set to an instance of an object'

Why???Hello Steve,

did you check that u have this variable in the context in receiver?

--
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

SHi All
S>
SI have an asp.net 2.0 web with a standard login control
S>
SI want to pass some extra variables to the redirected page after the
Ssuccessful login
S>
SI just can't get it to work. help much appreciated
S>
S---------------------
S------
S>
SProtected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As
SSystem.Web.UI.WebControls.AuthenticateEventArgs) Handles
SLogin1.Authenticate
S>
SContext.Items.Clear()
S>
SContext.Items.Add("UserNamevalue", Me.Login1.UserName)
S>
SContext.Items.Add("mydbkeyvalue", 2)
S>
SFormsAuthentication.RedirectFromLoginPage("steve", False)
S>
SServer.Transfer("~/memberpages/demos.aspx", True)
S>
SEnd If
S>
SCatch ex As Exception
S>
SResponse.Write(ex.Message)
S>
SEnd Try
S>
SEnd Sub
S>
S---------------------
S-------------------
S>
SIn a link button onclick event on the demos.aspx
S>
SMe.lblsamupdate.Text = "Context " &
SContext.Items("UserNamevalue").ToString
S>
SI get error 'Object reference not set to an instance of an object'
S>
SWhy???
S>
Steve.
I don't see how you can expect this to work:

FormsAuthentication.RedirectFromLoginPage("steve", False)
Server.Transfer("~/memberpages/demos.aspx", True)

Your first line causes the browser to request the redirect page.
the second line (Server.Transfer) will never execute.

Also, you could either stick the items into a cookie(s) or put them in
Session.

-- Peter
// Abandon all hope, ye who enter here.
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"Steve" wrote:

Quote:

Originally Posted by

Hi All
>
I have an asp.net 2.0 web with a standard login control
>
I want to pass some extra variables to the redirected page after the successful login
>
I just can't get it to work. help much appreciated
>
--------------------------
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
>
Context.Items.Clear()
>
Context.Items.Add("UserNamevalue", Me.Login1.UserName)
>
Context.Items.Add("mydbkeyvalue", 2)
>
FormsAuthentication.RedirectFromLoginPage("steve", False)
>
Server.Transfer("~/memberpages/demos.aspx", True)
>
End If
>
Catch ex As Exception
>
Response.Write(ex.Message)
>
End Try
>
End Sub
>
---------------------------------------
>
In a link button onclick event on the demos.aspx
>
Me.lblsamupdate.Text = "Context " & Context.Items("UserNamevalue").ToString
>
I get error 'Object reference not set to an instance of an object'
>
>
>
Why???
>

Passing Variable Across Secure Pages

Hey Bros:

I'm new to asp.net obviously, and am working on trying to put together my first website. I need help passing variables across multiple forms then trying to query a sql database based on the data which is passed.

What I have is
page one, datalist with a button when clicked will redirect to a page in a directory protected using forms authentication, user will be redirected to log in, once logged in the are redirected to the original destination page.

page two, will show the items, and details of the page which corresponds to the button the visitor originally choose.

I know I basicly have to create something to grab the value on the original page, and then on the destination page create something to grab the value, then perform an SQL statement agianst the value which was orignally grabbed from the first page. I just cannot find code which I can understand to do this. Any help would be greatly appreciated!Well one step at a time will take you far places...

You can easily preserve the data in a form item by enabling viewstate on the form by adding the following syntax enabledviewstate="true" This uses more system resources though and should not be enabled for form items that do not need it.

You were saying that you want to pass data from here to there etc... Well in asp.net you really do not have to and can code your entire program into one asp.net which eliminates passing values to and from. Ever hear about asp.net panels? A good book I would recommend is ASP.NET UNLEASHED by: Stephen Walther, if you are just starting out... I will track this thread to see if you have any other Q's...

Passing Variable Between Webforms

I'm a little new to this .NET jazz so my question may be a little trivial but how do you pass variables between webforms?If you are coming from an ASP background, it's pretty much the same.. you can pass variables with the querystring, Server.Transfer(), Session, or a datbase solution. In .NET you can also use the Cache object if the data is of Application scope (everyone is using the same value).

Saturday, March 24, 2012

Passing Variables

I have a asp page named welcome.asp where I have three input text
fields and a button named submit.
When I fill text in these text fields and click on button it passes
all those information to another aspx page.
the difference is my source page is written in classic asp and my
destination page is aspx.
Is this possible to pass values from asp page to aspx page. If so,
could you please send me xsom code.

Thanks,On Jun 11, 11:41 pm, bba...@.yahoo.com wrote:

Quote:

Originally Posted by

I have a asp page named welcome.asp where I have three input text
fields and a button named submit.
When I fill text in these text fields and click on button it passes
all those information to another aspx page.
the difference is my source page is written in classic asp and my
destination page is aspx.
Is this possible to pass values from asp page to aspx page. If so,
could you please send me xsom code.
>
Thanks,


Request.Form["text_field_from_asp"] ?
On Jun 11, 2:45 pm, Alexey Smirnov <alexey.smir...@.gmail.comwrote:

Quote:

Originally Posted by

On Jun 11, 11:41 pm, bba...@.yahoo.com wrote:
>

Quote:

Originally Posted by

I have a asp page named welcome.asp where I have three input text
fields and a button named submit.
When I fill text in these text fields and click on button it passes
all those information to another aspx page.
the difference is my source page is written in classic asp and my
destination page is aspx.
Is this possible to pass values from asp page to aspx page. If so,
could you please send me xsom code.


>

Quote:

Originally Posted by

Thanks,


>
Request.Form["text_field_from_asp"] ?


Is Request.form should be in destination web form or source webform.
<bbawa1@.yahoo.comwrote in message
news:1181603240.417819.11150@.a26g2000pre.googlegro ups.com...

Quote:

Originally Posted by

On Jun 11, 2:45 pm, Alexey Smirnov <alexey.smir...@.gmail.comwrote:

Quote:

Originally Posted by

>On Jun 11, 11:41 pm, bba...@.yahoo.com wrote:
>>

Quote:

Originally Posted by

I have a asp page named welcome.asp where I have three input text
fields and a button named submit.
When I fill text in these text fields and click on button it passes
all those information to another aspx page.
the difference is my source page is written in classic asp and my
destination page is aspx.
Is this possible to pass values from asp page to aspx page. If so,
could you please send me xsom code.


>>

Quote:

Originally Posted by

Thanks,


>>
>Request.Form["text_field_from_asp"] ?


>
Is Request.form should be in destination web form or source webform.
>


http://groups.google.com/group/micr...5addf17bc2a9da2

Passing Variables

Hi. I need to be able to pass a few variables on a button click to refill a
form on a new page. I am using a few textbox's but when the button is
clicked the values are lost - I am convinced that these variables are being
disposed - but why? - and how can I fix it.

thanks
JamesAnd make sure you're not resetting the values in your Page_Load by testing
for !IsPostBack before initializing any values. Keep in mind that Page_Load
runs before your button event.

Dale

"James" <James@.REMOVEMEtamarsolutions.co.uk> wrote in message
news:cahrpo$4lt$1@.newsg1.svr.pol.co.uk...
> Hi. I need to be able to pass a few variables on a button click to refill
a
> form on a new page. I am using a few textbox's but when the button is
> clicked the values are lost - I am convinced that these variables are
being
> disposed - but why? - and how can I fix it.
> thanks
> James

passing variables

Hi,

I have this (thanks Clint) which I have modified slightly from Clints code.

using System;

namespace NewsGroupHelpASPNET
{
/// <summary>
/// Summary description for MyPage.
/// </summary>
public class PageClass
{
private Table tables;
private StringBuilder sb = null;

public PageClass()
{
}

public void WriteText(string textToWrite)
{
sb.Append(textToWrite)
}

public Table Tables
{
get { return this.tables; }
set { this.tables = value; }
}
}
public class Table
{
private Row[] rows;
public Table()
{

}
public Row[] Rows
{
get { return this.rows; }
set { this.rows = value; }
}
public Add(int Rows, int Cols)
{
}
public Close()
{
}
}
public class Row
{
private Cell[] cells;
public Row()
{

}
public Cell[] Cells
{
get { return this.cells; }
set { this.cells = value; }
}
}
public class Cell
{
private string cellText;
public Cell()
{

}
public string Text
{
get { return this.cellText; }
set { this.cellText = value; }
}
}
}

When I do table.Add(2, 2), I need to add some text into the StringBuilder sb
which is in the top level class PageClass. I will also need to do this
within the Row and Cell as well as Text.

On top of this, the 2, 2 in the Add, I will need to store somewhere so that
Row and Cell can access them.

Thanks for any help you can offer.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises availableAnybody?

Best regards,
Dave Colliver.
http://www.CoventryFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"David" <david.colliver.NEWS@.revilloc.REMOVETHIS.com> wrote in message
news:uKRCNuTkFHA.2444@.tk2msftngp13.phx.gbl...
> Hi,
> I have this (thanks Clint) which I have modified slightly from Clints
> code.
> using System;
> namespace NewsGroupHelpASPNET
> {
> /// <summary>
> /// Summary description for MyPage.
> /// </summary>
> public class PageClass
> {
> private Table tables;
> private StringBuilder sb = null;
> public PageClass()
> {
> }
> public void WriteText(string textToWrite)
> {
> sb.Append(textToWrite)
> }
> public Table Tables
> {
> get { return this.tables; }
> set { this.tables = value; }
> }
> }
> public class Table
> {
> private Row[] rows;
> public Table()
> {
> }
> public Row[] Rows
> {
> get { return this.rows; }
> set { this.rows = value; }
> }
> public Add(int Rows, int Cols)
> {
> }
> public Close()
> {
> }
> }
> public class Row
> {
> private Cell[] cells;
> public Row()
> {
> }
> public Cell[] Cells
> {
> get { return this.cells; }
> set { this.cells = value; }
> }
> }
> public class Cell
> {
> private string cellText;
> public Cell()
> {
> }
> public string Text
> {
> get { return this.cellText; }
> set { this.cellText = value; }
> }
> }
> }
>
> When I do table.Add(2, 2), I need to add some text into the StringBuilder
> sb which is in the top level class PageClass. I will also need to do this
> within the Row and Cell as well as Text.
> On top of this, the 2, 2 in the Add, I will need to store somewhere so
> that Row and Cell can access them.
> Thanks for any help you can offer.
> Best regards,
> Dave Colliver.
> http://www.AshfieldFOCUS.com
> ~~
> http://www.FOCUSPortals.com - Local franchises available
Anybody?

Best regards,
Dave Colliver.
http://www.CoventryFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"David" <david.colliver.NEWS@.revilloc.REMOVETHIS.com> wrote in message
news:uKRCNuTkFHA.2444@.tk2msftngp13.phx.gbl...
> Hi,
> I have this (thanks Clint) which I have modified slightly from Clints
> code.
> using System;
> namespace NewsGroupHelpASPNET
> {
> /// <summary>
> /// Summary description for MyPage.
> /// </summary>
> public class PageClass
> {
> private Table tables;
> private StringBuilder sb = null;
> public PageClass()
> {
> }
> public void WriteText(string textToWrite)
> {
> sb.Append(textToWrite)
> }
> public Table Tables
> {
> get { return this.tables; }
> set { this.tables = value; }
> }
> }
> public class Table
> {
> private Row[] rows;
> public Table()
> {
> }
> public Row[] Rows
> {
> get { return this.rows; }
> set { this.rows = value; }
> }
> public Add(int Rows, int Cols)
> {
> }
> public Close()
> {
> }
> }
> public class Row
> {
> private Cell[] cells;
> public Row()
> {
> }
> public Cell[] Cells
> {
> get { return this.cells; }
> set { this.cells = value; }
> }
> }
> public class Cell
> {
> private string cellText;
> public Cell()
> {
> }
> public string Text
> {
> get { return this.cellText; }
> set { this.cellText = value; }
> }
> }
> }
>
> When I do table.Add(2, 2), I need to add some text into the StringBuilder
> sb which is in the top level class PageClass. I will also need to do this
> within the Row and Cell as well as Text.
> On top of this, the 2, 2 in the Add, I will need to store somewhere so
> that Row and Cell can access them.
> Thanks for any help you can offer.
> Best regards,
> Dave Colliver.
> http://www.AshfieldFOCUS.com
> ~~
> http://www.FOCUSPortals.com - Local franchises available

Passing Variables

Hi,

What's the preferred way to pass variables around to different pages now?
Or if my reading servers me right they are retained in memory for the life of
the app, correct? How do I access these variables if in a different page than
the one variable was created in?

Thanks,

JJHere's one way to pass values from one .aspx page to another:

http://authors.aspalliance.com/kenc/passval.aspx

"JJ" wrote:

> Hi,
> What's the preferred way to pass variables around to different pages now?
> Or if my reading servers me right they are retained in memory for the life of
> the app, correct? How do I access these variables if in a different page than
> the one variable was created in?
> Thanks,
> JJ
Ken,

Is it possible to create a separate class to house my variables and in one
page create the varaibles class and then in another page call that varaibles
class again to get the values set?

Thanks,

JJ

"Ken Cox [Microsoft MVP]" wrote:

> Here's one way to pass values from one .aspx page to another:
> http://authors.aspalliance.com/kenc/passval.aspx
>
> "JJ" wrote:
> > Hi,
> > What's the preferred way to pass variables around to different pages now?
> > Or if my reading servers me right they are retained in memory for the life of
> > the app, correct? How do I access these variables if in a different page than
> > the one variable was created in?
> > Thanks,
> > JJ
I'm not sure of the preferred way but what I usually use to accomplish
this is session state variables that are only "alive" for as long as I
need them. An example:

// Page one
private void transfer(string state, string varname)
{
Session.add(state, varname);
Response.redirect("pagetwo.aspx");
}

// Page two
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack) {
TextBox1.Text = (string)Session[<whatever state variable was above>];
}
}

Not exactly functional but it gets the point across anyway. If there's
a better way, I'd love to know!

James

JJ wrote:

> Hi,
> What's the preferred way to pass variables around to different
> pages now? Or if my reading servers me right they are retained in
> memory for the life of the app, correct? How do I access these
> variables if in a different page than the one variable was created in?
> Thanks,
> JJ
HI JJ:

Yes, one way to do this would be to create an instance of the class
and set all the properties, then add a reference to the class to
HttpContext.Current.Items. The Items collection is around for the
duration of the request. When you get to the next page with
Server.Transfer you can pull the reference out of the Items collection
and party on the values.

HTH,

--
Scott
http://www.OdeToCode.com/

On Wed, 6 Oct 2004 09:51:01 -0700, "JJ" <JJ@.discussions.microsoft.com>
wrote:

>Ken,
> Is it possible to create a separate class to house my variables and in one
>page create the varaibles class and then in another page call that varaibles
>class again to get the values set?
>Thanks,
>JJ
>"Ken Cox [Microsoft MVP]" wrote:
>> Here's one way to pass values from one .aspx page to another:
>>
>> http://authors.aspalliance.com/kenc/passval.aspx
>>
>>
>> "JJ" wrote:
>>
>>> > Hi,
>>> > What's the preferred way to pass variables around to different pages now?
>> > Or if my reading servers me right they are retained in memory for the life of
>> > the app, correct? How do I access these variables if in a different page than
>> > the one variable was created in?
>>> > Thanks,
>>> > JJ
Hi Scott,

To add a reference to a class to HttpCOntext.Current.Items. Can you show me
in C# how to do this?

Thanks,
JJ

"Scott Allen" wrote:

> HI JJ:
> Yes, one way to do this would be to create an instance of the class
> and set all the properties, then add a reference to the class to
> HttpContext.Current.Items. The Items collection is around for the
> duration of the request. When you get to the next page with
> Server.Transfer you can pull the reference out of the Items collection
> and party on the values.
> HTH,
> --
> Scott
> http://www.OdeToCode.com/
> On Wed, 6 Oct 2004 09:51:01 -0700, "JJ" <JJ@.discussions.microsoft.com>
> wrote:
> >Ken,
> > Is it possible to create a separate class to house my variables and in one
> >page create the varaibles class and then in another page call that varaibles
> >class again to get the values set?
> >Thanks,
> >JJ
> >"Ken Cox [Microsoft MVP]" wrote:
> >> Here's one way to pass values from one .aspx page to another:
> >>
> >> http://authors.aspalliance.com/kenc/passval.aspx
> >>
> >>
> >> "JJ" wrote:
> >>
> >> >> > Hi,
> >> >> > What's the preferred way to pass variables around to different pages now?
> >> > Or if my reading servers me right they are retained in memory for the life of
> >> > the app, correct? How do I access these variables if in a different page than
> >> > the one variable was created in?
> >> >> > Thanks,
> >> >> > JJ
>
Sure!

Let's say you are inside a web form code behind file, and you already
have a class defined, like for a Person:

public class Person
{
public Person(string name)
{
Name = name;
}

public string Name = String.Empty;
}

In the Page_Load even handler we can create an instance of person and
stick the reference into the Items collection, than transfer to a
different aspx page:

private void Page_Load(object sender, System.EventArgs e)
{

Person p = new Person("Milo Finkledoodle");
Context.Items["Person"] = p;

Server.Transfer("destination.aspx");

}

Inside of detination.aspx, we can pull this reference out and retrieve
the person's name:

private void Page_Load(object sender, System.EventArgs e)
{
p = Context.Items["Person"] as Person;
Response.Write(p.Name);
}

Inside a page you can reach the current context with the Context
property. If you are not writing code in a page class you can still
access the current context like so:

Person p = HttpContext.Current.Items["Person"] as Person;

Just make sure to add "using System.Web;" at the top of the cs file.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 6 Oct 2004 11:23:03 -0700, "JJ" <JJ@.discussions.microsoft.com>
wrote:

>Hi Scott,
>To add a reference to a class to HttpCOntext.Current.Items. Can you show me
>in C# how to do this?
>Thanks,
>JJ
>"Scott Allen" wrote:
>> HI JJ:
>>
>> Yes, one way to do this would be to create an instance of the class
>> and set all the properties, then add a reference to the class to
>> HttpContext.Current.Items. The Items collection is around for the
>> duration of the request. When you get to the next page with
>> Server.Transfer you can pull the reference out of the Items collection
>> and party on the values.
>>
>> HTH,
>>
>> --
>> Scott
>> http://www.OdeToCode.com/
>>
>> On Wed, 6 Oct 2004 09:51:01 -0700, "JJ" <JJ@.discussions.microsoft.com>
>> wrote:
>>
>> >Ken,
>>> > Is it possible to create a separate class to house my variables and in one
>> >page create the varaibles class and then in another page call that varaibles
>> >class again to get the values set?
>>> >Thanks,
>>> >JJ
>>> >"Ken Cox [Microsoft MVP]" wrote:
>>> >> Here's one way to pass values from one .aspx page to another:
>> >>
>> >> http://authors.aspalliance.com/kenc/passval.aspx
>> >>
>> >>
>> >> "JJ" wrote:
>> >>
>> >>> >> > Hi,
>> >>> >> > What's the preferred way to pass variables around to different pages now?
>> >> > Or if my reading servers me right they are retained in memory for the life of
>> >> > the app, correct? How do I access these variables if in a different page than
>> >> > the one variable was created in?
>> >>> >> > Thanks,
>> >>> >> > JJ
>>
>
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'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)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
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

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"JJ" <JJ@.discussions.microsoft.com> wrote in message
news:27E33A9D-D214-4C86-9771-FB0EE8FE9631@.microsoft.com...
> Hi,
> What's the preferred way to pass variables around to different pages now?
> Or if my reading servers me right they are retained in memory for the life
> of
> the app, correct? How do I access these variables if in a different page
> than
> the one variable was created in?
> Thanks,
> JJ
Thanks Scott !!!

"Scott Allen" wrote:

> Sure!
> Let's say you are inside a web form code behind file, and you already
> have a class defined, like for a Person:
> public class Person
> {
> public Person(string name)
> {
> Name = name;
> }
> public string Name = String.Empty;
> }
> In the Page_Load even handler we can create an instance of person and
> stick the reference into the Items collection, than transfer to a
> different aspx page:
> private void Page_Load(object sender, System.EventArgs e)
> {
> Person p = new Person("Milo Finkledoodle");
> Context.Items["Person"] = p;
> Server.Transfer("destination.aspx");
> }
>
> Inside of detination.aspx, we can pull this reference out and retrieve
> the person's name:
> private void Page_Load(object sender, System.EventArgs e)
> {
> p = Context.Items["Person"] as Person;
> Response.Write(p.Name);
> }
> Inside a page you can reach the current context with the Context
> property. If you are not writing code in a page class you can still
> access the current context like so:
> Person p = HttpContext.Current.Items["Person"] as Person;
> Just make sure to add "using System.Web;" at the top of the cs file.
> HTH,
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
>
> On Wed, 6 Oct 2004 11:23:03 -0700, "JJ" <JJ@.discussions.microsoft.com>
> wrote:
> >Hi Scott,
> >To add a reference to a class to HttpCOntext.Current.Items. Can you show me
> >in C# how to do this?
> >Thanks,
> >JJ
> >"Scott Allen" wrote:
> >> HI JJ:
> >>
> >> Yes, one way to do this would be to create an instance of the class
> >> and set all the properties, then add a reference to the class to
> >> HttpContext.Current.Items. The Items collection is around for the
> >> duration of the request. When you get to the next page with
> >> Server.Transfer you can pull the reference out of the Items collection
> >> and party on the values.
> >>
> >> HTH,
> >>
> >> --
> >> Scott
> >> http://www.OdeToCode.com/
> >>
> >> On Wed, 6 Oct 2004 09:51:01 -0700, "JJ" <JJ@.discussions.microsoft.com>
> >> wrote:
> >>
> >> >Ken,
> >> >> > Is it possible to create a separate class to house my variables and in one
> >> >page create the varaibles class and then in another page call that varaibles
> >> >class again to get the values set?
> >> >> >Thanks,
> >> >> >JJ
> >> >> >"Ken Cox [Microsoft MVP]" wrote:
> >> >> >> Here's one way to pass values from one .aspx page to another:
> >> >>
> >> >> http://authors.aspalliance.com/kenc/passval.aspx
> >> >>
> >> >>
> >> >> "JJ" wrote:
> >> >>
> >> >> >> >> > Hi,
> >> >> >> >> > What's the preferred way to pass variables around to different pages now?
> >> >> > Or if my reading servers me right they are retained in memory for the life of
> >> >> > the app, correct? How do I access these variables if in a different page than
> >> >> > the one variable was created in?
> >> >> >> >> > Thanks,
> >> >> >> >> > JJ
> >>
> >>
>

Passing Variables

I would like to pass variables on a button click to another module that is not visible until it gets the variables from the first module. First, can this be done? If so, how?

I found some articles on how to pass variables using server.transfer but I do not know if this will work or not because I want to use .ascx files.

Any thoughts?Hi,

you can pass information to the user control by creating properties on the control, fill them up through your page in a button click eventhandler or so.

Grz, Kris.

passing variables

hi,

When my user logs on they suppy a username thats checked off a db to allow access. This username is the unique identifier for all queries that are run throughout the access. What is the best way to pass this between pages. I will have a number of clients accessing at the same time. The variable is a six character alphanumeric.

any ideas will be accepted gratefully....oh security is a key issue as i dont want users getting access to eachothers identifier.

tia

pecSee if below two links could helps for your question

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskpassingvaluesbetweenwebformspages.asp

and

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpassingservercontrolvaluesbetweenpages.asp

If not you could capture the value in sessions and you can use it in all the pages!

Hope it helps!
hi

i followed the first links eg...but when i use sourcepage.property1 it isnt within the object

any ideas

pec
In this given example in first page he given a property1 as property, so if you have that then only you will able to access it!

Hope it helps!
hi,

I had set the property code with in my <script> in html. When i moved it to the vb it worked but when i ran it the called page gave this error...even though i have placed the Public sourcepage As WebForm1 in the right place?

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'sourcepage' is not declared.

Source Error:

Line 15:
Line 16: If Not IsPostBack Then
Line 17: sourcepage = CType(Context.Handler, logon)
Line 18: dim strUserName as string = sourcepage.Username
Line 19: mydatagrid.Visible = False

tia pec
Declare sourcepage, then use it!

Ex: Dim sourcepage As PreviousPage

In this case PreviousPage is the first page reference name!

That could solve your problem!

Passing variables

I have just started using .net and have a question about passing variables from one page to another.
I have found several tutorials on the subject but none that fit my issue. Here it is.
I have a page1.aspx that hashttp://www.domain.com/directory/index.aspx?tagID=name
In page2.aspx I have
<script runat="server">
Sub Page_load
Dim tagID As String = Request.QueryString("tagID")
End Sub
</script>
<body>
<form runat="server">
& tagID
</form>
</body>
And it is not working. Can someone let me know what I am doing wrong?
Thanks.

First of all, in Asp.net you should always make sure that the QueryString (also Session, ViewState etc) object has a value. If it doesn't, you'll get an exception if you try to use it:
<SCRIPT runat="server"> Sub Page_load() If Not IsPostBack Then If Not Request.QueryString("tagID") Is Nothing Then Dim tagID As String = Request.QueryString("tagID") lbl.Text = Request.QueryString("tagID") End If End If End Sub</SCRIPT><FORM runat="server"> <body> asp:label id="lbl" runat="server"></asp:label> </body></FORM>
Asp.Net is a whole different ballgame that Classic Asp, and would recommend you to pick up one of the many fine books on how to get started. My favourite suggestion is Asp.Net Unleahed, written by Stephen Walther (SAMS).

Inhttp://www.domain.com/directory/index.aspx?tagID=name,
shouldn't it be
http://www.domain.com/directory/page2.aspx?tagID=name


Just a note, if you are passing sensitive data make sure not to pass them by QueryStrings. You might check other solutions, safer to a certain extent.

Regards

hi
why dont you try theContext.Handlermethod for passing variables data into one form to another.
it is Pretty good & secure compare with other techniques(Qureystring)
through this you can create object of the one into another forms and access the variales.
i think it might be usefull for you
tegards
Rams123
When you make suggestions like this, you should also provide at least a link to examples on how to do it. Better yet, include some code to demonstrate. Otherwise we will have a lot of unnecessary postings back and forth. This is the poster's first, and he clearly states that he just started out with .Net. It's therefore more than doubtful that he has a clue what Context.Handler is about.
You should also all set your preferred programming language in your profiles to ensure that eventual code examples will hopefully be given in this language.
Thanks in advance.
I found this article helpful when I was learning this.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskpassingvaluesbetweenwebformspages.asp
Well its a very simple mistake. You declared tagID inside Page_Load event, so they scope of that varibale is only upto Page_Load which you cannot access outside that procedure. simply make it global and you can access.so your code shoulde b like this
<script runat="server">
Dim tagID As String
Sub Page_load
tagID = Request.QueryString("tagID")
End Sub
</script>
<body>
<form runat="server">
' Now here you can use tagID variable as it has page level scope now
</form>
</body>

Hope I am clear. ..

Worked perfectly! Thank you.

Passing Variables

This is from an earlier thread:

www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=133432

I am getting zero for my variable the second time it accesses the subrountine. It is obivous to me that its getting initialized every time, thus reseting it to zero.

How can I initialize the variable once and not have it re-initialized every time? What is the syntax?

Thanks for the help,

-JJust a swag, but are you checking "IsPostBack" in your PageLoad before initializing the variables?

Another thing to remember is that no variables survive a roundtrip to the client. You have to save them somewhere (viewstate, session), and restore their values each time.
I am not sure what you are asking? I am checking for IsPostBack in Page Load, but the variable that is in question is not declared up there, but within the subroutine. When I used to program in PICK it was always good practice to declare your variables at the top of the program and you never had to declare them again. Seems in ASP.NET you, its geared for option explicit, which makes it difficult sometimes when you have to declare everytime you want to use the same variable more than one place in the program.

I did think of this earlier although, but I was getting an undeclared error when I intialized it in the page load.

How do you use the viewstate to handle something like this?

Thanks for you help so far,

-J
In VB.NET or C#.net, you can declare variables at the "class" level. For example:


Public Class MyPage
Inherits System.Web.UI.Page

Protected dateBegin As System.DateTime
Protected dateEnd As System.DateTime
etc.

These will be accessable from anywhere in your code-behind, or from the ASPX page that inherits from the code-behind. Typically, then, within a function or sub, you can then use these without declaring them, but they will, of course, need to be initialized first. It is good practice to _only_ use this kind of variable for things that will be needed throughout the class. For variables that are only used within a function, you declare them withing the function. These go out of scope when you exit the function.

Viewstate is pretty simple to use. To store something there:
Viewstate("dateBegin") = dateBegin

To get it back, you need to cast the type:
dateBegin = CType(Viewstate("dateBegin"), System.DateTime)

========

Typically, with your begin/end variables you might do something like:


In page-load:
If Not IsPostBack Then
dateBegin = Date.Today()
dateEnd = dateBegin
Viewstate("dateBegin") = dateBegin
Else
dateBegin = CType(Viewstate("dateBegin"), DateTime)
dateEnd = Date.Today()
End If

Now, if you declared the two dates as "Protected... " at the class level, you can access them in any function that runs after PageLoad in the processing cycle. (and postback handlers DO run after PageLoad).

HTH,
Wow, thank you so much for this explanation. I've also been searching and couldn't find why my variable values where disappearing.

Passing Variables

Hi,
What's the preferred way to pass variables around to different pages now?
Or if my reading servers me right they are retained in memory for the life o
f
the app, correct? How do I access these variables if in a different page tha
n
the one variable was created in?
Thanks,
JJHere's one way to pass values from one .aspx page to another:
http://authors.aspalliance.com/kenc/passval.aspx
"JJ" wrote:

> Hi,
> What's the preferred way to pass variables around to different pages now
?
> Or if my reading servers me right they are retained in memory for the life
of
> the app, correct? How do I access these variables if in a different page t
han
> the one variable was created in?
> Thanks,
> JJ
Ken,
Is it possible to create a separate class to house my variables and in one
page create the varaibles class and then in another page call that varaibles
class again to get the values set?
Thanks,
JJ
"Ken Cox [Microsoft MVP]" wrote:
> Here's one way to pass values from one .aspx page to another:
> http://authors.aspalliance.com/kenc/passval.aspx
>
> "JJ" wrote:
>
HI JJ:
Yes, one way to do this would be to create an instance of the class
and set all the properties, then add a reference to the class to
HttpContext.Current.Items. The Items collection is around for the
duration of the request. When you get to the next page with
Server.Transfer you can pull the reference out of the Items collection
and party on the values.
HTH,
Scott
http://www.OdeToCode.com/
On Wed, 6 Oct 2004 09:51:01 -0700, "JJ" <JJ@.discussions.microsoft.com>
wrote:
>Ken,
> Is it possible to create a separate class to house my variables and in on
e
>page create the varaibles class and then in another page call that varaible
s
>class again to get the values set?
>Thanks,
>JJ
>"Ken Cox [Microsoft MVP]" wrote:
>
I'm not sure of the preferred way but what I usually use to accomplish
this is session state variables that are only "alive" for as long as I
need them. An example:
// Page one
private void transfer(string state, string varname)
{
Session.add(state, varname);
Response.redirect("pagetwo.aspx");
}
// Page two
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack) {
TextBox1.Text = (string)Session[<whatever state variable was above>];
}
}
Not exactly functional but it gets the point across anyway. If there's
a better way, I'd love to know!
James
JJ wrote:

> Hi,
> What's the preferred way to pass variables around to different
> pages now? Or if my reading servers me right they are retained in
> memory for the life of the app, correct? How do I access these
> variables if in a different page than the one variable was created in?
> Thanks,
> JJ
Hi Scott,
To add a reference to a class to HttpCOntext.Current.Items. Can you show me
in C# how to do this?
Thanks,
JJ
"Scott Allen" wrote:

> HI JJ:
> Yes, one way to do this would be to create an instance of the class
> and set all the properties, then add a reference to the class to
> HttpContext.Current.Items. The Items collection is around for the
> duration of the request. When you get to the next page with
> Server.Transfer you can pull the reference out of the Items collection
> and party on the values.
> HTH,
> --
> Scott
> http://www.OdeToCode.com/
> On Wed, 6 Oct 2004 09:51:01 -0700, "JJ" <JJ@.discussions.microsoft.com>
> wrote:
>
>
Sure!
Let's say you are inside a web form code behind file, and you already
have a class defined, like for a Person:
public class Person
{
public Person(string name)
{
Name = name;
}
public string Name = String.Empty;
}
In the Page_Load even handler we can create an instance of person and
stick the reference into the Items collection, than transfer to a
different aspx page:
private void Page_Load(object sender, System.EventArgs e)
{
Person p = new Person("Milo Finkledoodle");
Context.Items["Person"] = p;
Server.Transfer("destination.aspx");
}
Inside of detination.aspx, we can pull this reference out and retrieve
the person's name:
private void Page_Load(object sender, System.EventArgs e)
{
p = Context.Items["Person"] as Person;
Response.Write(p.Name);
}
Inside a page you can reach the current context with the Context
property. If you are not writing code in a page class you can still
access the current context like so:
Person p = HttpContext.Current.Items["Person"] as Person;
Just make sure to add "using System.Web;" at the top of the cs file.
HTH,
Scott
http://www.OdeToCode.com/blogs/scott/
On Wed, 6 Oct 2004 11:23:03 -0700, "JJ" <JJ@.discussions.microsoft.com>
wrote:
>Hi Scott,
>To add a reference to a class to HttpCOntext.Current.Items. Can you show me
>in C# how to do this?
>Thanks,
>JJ
>"Scott Allen" wrote:
>
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)
'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)
Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
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
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"JJ" <JJ@.discussions.microsoft.com> wrote in message
news:27E33A9D-D214-4C86-9771-FB0EE8FE9631@.microsoft.com...
> Hi,
> What's the preferred way to pass variables around to different pages now?
> Or if my reading servers me right they are retained in memory for the life
> of
> the app, correct? How do I access these variables if in a different page
> than
> the one variable was created in?
> Thanks,
> JJ
Thanks Scott !!!
"Scott Allen" wrote:

> Sure!
> Let's say you are inside a web form code behind file, and you already
> have a class defined, like for a Person:
> public class Person
> {
> public Person(string name)
> {
> Name = name;
> }
> public string Name = String.Empty;
> }
> In the Page_Load even handler we can create an instance of person and
> stick the reference into the Items collection, than transfer to a
> different aspx page:
> private void Page_Load(object sender, System.EventArgs e)
> {
> Person p = new Person("Milo Finkledoodle");
> Context.Items["Person"] = p;
> Server.Transfer("destination.aspx");
> }
>
> Inside of detination.aspx, we can pull this reference out and retrieve
> the person's name:
> private void Page_Load(object sender, System.EventArgs e)
> {
> p = Context.Items["Person"] as Person;
> Response.Write(p.Name);
> }
> Inside a page you can reach the current context with the Context
> property. If you are not writing code in a page class you can still
> access the current context like so:
> Person p = HttpContext.Current.Items["Person"] as Person;
> Just make sure to add "using System.Web;" at the top of the cs file.
> HTH,
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
>
> On Wed, 6 Oct 2004 11:23:03 -0700, "JJ" <JJ@.discussions.microsoft.com>
> wrote:
>
>

passing variables

Hi,
I have this (thanks Clint) which I have modified slightly from Clints code.
using System;
namespace NewsGroupHelpASPNET
{
/// <summary>
/// Summary description for MyPage.
/// </summary>
public class PageClass
{
private Table tables;
private StringBuilder sb = null;
public PageClass()
{
}
public void WriteText(string textToWrite)
{
sb.Append(textToWrite)
}
public Table Tables
{
get { return this.tables; }
set { this.tables = value; }
}
}
public class Table
{
private Row[] rows;
public Table()
{
}
public Row[] Rows
{
get { return this.rows; }
set { this.rows = value; }
}
public Add(int Rows, int Cols)
{
}
public Close()
{
}
}
public class Row
{
private Cell[] cells;
public Row()
{
}
public Cell[] Cells
{
get { return this.cells; }
set { this.cells = value; }
}
}
public class Cell
{
private string cellText;
public Cell()
{
}
public string Text
{
get { return this.cellText; }
set { this.cellText = value; }
}
}
}
When I do table.Add(2, 2), I need to add some text into the StringBuilder sb
which is in the top level class PageClass. I will also need to do this
within the Row and Cell as well as Text.
On top of this, the 2, 2 in the Add, I will need to store somewhere so that
Row and Cell can access them.
Thanks for any help you can offer.
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises availableAnybody?
Best regards,
Dave Colliver.
http://www.CoventryFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"David" <david.colliver.NEWS@.revilloc.REMOVETHIS.com> wrote in message
news:uKRCNuTkFHA.2444@.tk2msftngp13.phx.gbl...
> Hi,
> I have this (thanks Clint) which I have modified slightly from Clints
> code.
> using System;
> namespace NewsGroupHelpASPNET
> {
> /// <summary>
> /// Summary description for MyPage.
> /// </summary>
> public class PageClass
> {
> private Table tables;
> private StringBuilder sb = null;
> public PageClass()
> {
> }
> public void WriteText(string textToWrite)
> {
> sb.Append(textToWrite)
> }
> public Table Tables
> {
> get { return this.tables; }
> set { this.tables = value; }
> }
> }
> public class Table
> {
> private Row[] rows;
> public Table()
> {
> }
> public Row[] Rows
> {
> get { return this.rows; }
> set { this.rows = value; }
> }
> public Add(int Rows, int Cols)
> {
> }
> public Close()
> {
> }
> }
> public class Row
> {
> private Cell[] cells;
> public Row()
> {
> }
> public Cell[] Cells
> {
> get { return this.cells; }
> set { this.cells = value; }
> }
> }
> public class Cell
> {
> private string cellText;
> public Cell()
> {
> }
> public string Text
> {
> get { return this.cellText; }
> set { this.cellText = value; }
> }
> }
> }
>
> When I do table.Add(2, 2), I need to add some text into the StringBuilder
> sb which is in the top level class PageClass. I will also need to do this
> within the Row and Cell as well as Text.
> On top of this, the 2, 2 in the Add, I will need to store somewhere so
> that Row and Cell can access them.
> Thanks for any help you can offer.
> Best regards,
> Dave Colliver.
> http://www.AshfieldFOCUS.com
> ~~
> http://www.FOCUSPortals.com - Local franchises available
>

Passing Variables

Hi. I need to be able to pass a few variables on a button click to refill a
form on a new page. I am using a few textbox's but when the button is
clicked the values are lost - I am convinced that these variables are being
disposed - but why? - and how can I fix it.
thanks
JamesJames,
Check that EnableViewState is set to True in the page directive.
Hth,
Phil Winstanley
Microsoft ASP.NET MVP
http://www.myservicescentral.com
And make sure you're not resetting the values in your Page_Load by testing
for !IsPostBack before initializing any values. Keep in mind that Page_Load
runs before your button event.
Dale
"James" <James@.REMOVEMEtamarsolutions.co.uk> wrote in message
news:cahrpo$4lt$1@.newsg1.svr.pol.co.uk...
> Hi. I need to be able to pass a few variables on a button click to refill
a
> form on a new page. I am using a few textbox's but when the button is
> clicked the values are lost - I am convinced that these variables are
being
> disposed - but why? - and how can I fix it.
> thanks
> James
>
James,
Yes as Dale states, it's important to check you're not wiping out your
hard work in the Page_Load event! But make sure the order of your
events is right too, use the Trace to check, but as a rule of thumb,
try and do all page specific stuff in the PreRender event.
Hth,
Phil Winstanley
Microsoft ASP.NET MVP
http://www.myservicescentral.com

Passing variables

I need help passing some variables from an aspx page to a pop up window. I tried using querystring but somehow it's not passing it correctly. Below is what I have:

Mainpage code behind. This is pulling the user's name that the user enter at login. The session works for this.

Dim strAuthUsr as String

strAuthUsr = Session("AuthUsr")

This is where I put the tag:

Onclick = "windowOpen('http://intranet/Quotes/NewQuote.aspx?user=<%#strAuthUsr%>', 'NewQuote');"

New window that is being open from the javascript above that uses the querystring:

Dim strAuthUser As String

strAuthUsr = Request.QueryString("user")
txbUser.Text = strAuthUsr

The only thing output I got for that textbox is <%. I'm not sure if my syntax is right, but please advise.Why not:

Onclick = "windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUsr & "', 'NewQuote');"

You are constructing this in the code-behind, right?

Brian
<Elmer Fudd Voice>
Be veddy veddy karefull when using popups... huhuhuhuhuh...
</Elmer Fudd Voice
Most browsers block them by default these days, this can cause you ALOT of pain.

Just a thought.
Brian,

I tried using the syntax as you suggested, but I get an error. Says that the server tag is not well formed.

There's also squiggle line under the strAuthUsr string. Says that it could not find any attribute 'strAuthUsr' of element 'input'

Yes, I am constructing this in the code-behind.

The Quote.aspx.vb is coded as followed:


Dim strAuthUsr as String

strAuthUsr = Session("AuthUsr")

From the Quote.aspx is coded as followed:


Onclick="windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUser & "', 'NewQuote');"

This is for the pop window:


Dim strAuthUsr As String

strAuthUsr = Request.QueryString("user")

txbUser.Text = strAuthUsr

I want to pass the user name from session that the user entered to get into the main page to be displayed on the txbUser.Text textbox.

I can pass the variable from page to page, but somehow this pop up window is not letting me. I don't know if the javascript has anything to do with it, but I doubt it.

<script language="javascript">
function windowOpen(sURL,sWinName){
var params = 'height=410,width=450,directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=no,resizeable=no';
window.open(sURL,sWinName,params);
}
</script

Please advise.
Probably I should ask this. The string "strAuthUsr = Session("AuthUsr")" does show the username when I go to debug.

The

Onclick="windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUser & "', 'NewQuote');"
, I'm assuming should pull that variable. Is there a way to see if the username is being pull? I did try a
Response.Write("user")
, but all i'm getting is sometime <% or sometime nothing.

From my understanind the strAuthUsr string should be pass as variable when using <%#strAuthUsr%>, but I'm not sure why it's not doing that in this case.

Any suggestions on how I can do a generic pass, for example something static just to make sure that it does pass from one page to the next?
I beleive if you use my free controlPopUpWindow 1.1, you would have any problem. Since you can open a pop up window from inside server-side.

regards
For this to work, this can't be in aspx:

Onclick="windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUser & "', 'NewQuote');"

You need to add it in .aspx.vb file. You may be able to do this through the Attributes.Add, which would add it so that it would render directly as is on the client.

Brian
In addition, if the user name is stored in the Session, it may be better to keep it there, redirect to the page, and check the session for this value, instead of going server/client, and then most likely server again. Or are you posting it outside your web site.

Brian
Brian thanks for responding. I'm not really clear on your post. For the code that I posted


Onclick="windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUser & "', 'NewQuote');"

How could this be in aspx.vb file when this is for the aspx server tag? The entire code for this is like this.


<input id="btnNewQuote" type="button" Onclick="windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUser & "', 'NewQuote');"
value = "New Quote" runat="server" >

As for the session, it does not work because this is passing it from my page to a pop up window. I tried to call it from my previous page for the session variable and hopefully be able to pass it to the pop window, but it's not grabbing the value.

Any ideas?
I would recommend you check my control. It has what you need.

regards
haidar bilal, I had downloaded your control and will use it. If I have any questions, I will post you some.

Thanks.
Haidar Bilal,

Can your control open multiple pop up windows? I want to open a pop for users to fill in a small form, and from that pop up they can click on a button to open another pop where it has list of customers that they can click on to have those information filled in to the first pop up window.

So far, each pop up that i will replaces the current pop up window. WOndering if it can be done and how.

Thanks.
I hate to be redundent but you guys are going to need to be VERY carefull with popups. Almost all browsers have default popup blockers in them. Including IE6 with SP2 and Firefox 1.0.

Some popup blockers are even starting to block user execute popups.

You'll save yourself time and frustration if you avoid them.

Hope this helps,
Thanks for the warning adurstew, but this is for an intranet portal application. We had used it in the past with no problem so I don't see it as a concern.
Are your users running Windows XP? If so when your company rolls out SP2 a popup blocker is installed and running by default.

passing variables

When I try that it tells me that property is read - only!
any ideas.
thanks
Phil.
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%234djVFU1DHA.4032@dotnet.itags.org.tk2msftngp13.phx.gbl...
> I set mine into the
> Page.User.Identity.Name
> Then I always have the userID accessable across the app/site
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> www.Darkfalz.com
>
> "Phil Barber" <barber@dotnet.itags.org.galtney.com> wrote in message
> news:e3TFmBU1DHA.3196@dotnet.itags.org.TK2MSFTNGP11.phx.gbl...
> > I have a login page (page1) on successful login I retrieve an employeeID
> > from a SQL Database.
> > then move to a 2nd page. What is the best way to get the EmployeeID from
> > Page 1 to Page2
> > I have had problems with global variables in the past concerning
sessions.
> > thanks.
> > Phil BarberIt's when I use Forms Auth, like this
FormsAuthentication.SetAuthCookie(userID,false);

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com

"Phil Barber" <barber@.galtney.com> wrote in message
news:%23Go$s9U1DHA.4032@.tk2msftngp13.phx.gbl...
> When I try that it tells me that property is read - only!
> any ideas.
> thanks
> Phil.
> "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> news:%234djVFU1DHA.4032@.tk2msftngp13.phx.gbl...
> > I set mine into the
> > Page.User.Identity.Name
> > Then I always have the userID accessable across the app/site
> > --
> > Curt Christianson
> > Owner/Lead Developer, DF-Software
> > www.Darkfalz.com
> > "Phil Barber" <barber@.galtney.com> wrote in message
> > news:e3TFmBU1DHA.3196@.TK2MSFTNGP11.phx.gbl...
> > > I have a login page (page1) on successful login I retrieve an
employeeID
> > > from a SQL Database.
> > > then move to a 2nd page. What is the best way to get the EmployeeID
from
> > > Page 1 to Page2
> > > > I have had problems with global variables in the past concerning
> sessions.
> > > > thanks.
> > > > Phil Barber
> >

Passing Variables

I have a asp page named welcome.asp where I have three input text
fields and a button named submit.
When I fill text in these text fields and click on button it passes
all those information to another aspx page.
the difference is my source page is written in classic asp and my
destination page is aspx.
Is this possible to pass values from asp page to aspx page. If so,
could you please send me xsom code.
Thanks,On Jun 11, 11:41 pm, bba...@.yahoo.com wrote:
> I have a asp page named welcome.asp where I have three input text
> fields and a button named submit.
> When I fill text in these text fields and click on button it passes
> all those information to another aspx page.
> the difference is my source page is written in classic asp and my
> destination page is aspx.
> Is this possible to pass values from asp page to aspx page. If so,
> could you please send me xsom code.
> Thanks,
Request.Form["text_field_from_asp"] ?
On Jun 11, 2:45 pm, Alexey Smirnov <alexey.smir...@.gmail.com> wrote:
> On Jun 11, 11:41 pm, bba...@.yahoo.com wrote:
>
>
> Request.Form["text_field_from_asp"] ?
Is Request.form should be in destination web form or source webform.
<bbawa1@.yahoo.com> wrote in message
news:1181603240.417819.11150@.a26g2000pre.googlegroups.com...
> On Jun 11, 2:45 pm, Alexey Smirnov <alexey.smir...@.gmail.com> wrote:
> Is Request.form should be in destination web form or source webform.
>
http://groups.google.com/group/micr...5addf17bc2a9da2