Showing posts with label varaible. Show all posts
Showing posts with label varaible. Show all posts

Thursday, March 29, 2012

Session Variable

Hello...

I have a simple problem...when I create a session variable as such:

Session("ID") = 1

and read this varaible from time to time...

The problem is that it is shared by all users not just the user that
created the session variable...

That is, if another user logs on and sets

Session("ID") = 2

then this will change the value if Session("ID") for the first
user...

What I want is to have different ID's for each user...

Can someone elxplain what is wrong?

Thanks...It shouldn't happen and I've never seent that. Are you sure this is
System.Web.HttpContext.Current.Session and not some other cusom session
object. You can also dump the SessionID to see if this is the same value (is
this hardcoded somewhere ?). What if you do a bare bone sample that shoes
that in your dev server on a bare bone site. Do you have the same problem ?

Ah ! Do you open another window and test to check this ? Note that when you
open another window (without relancunhing i..e) the new window uses the same
session.

--
Patrice

"Flurry" <cj406168@.stmail.staffs.ac.uka crit dans le message de news:
1189422564.511977.244720@.d55g2000hsg.googlegroups. com...

Quote:

Originally Posted by

Hello...
>
I have a simple problem...when I create a session variable as such:
>
Session("ID") = 1
>
and read this varaible from time to time...
>
The problem is that it is shared by all users not just the user that
created the session variable...
>
That is, if another user logs on and sets
>
Session("ID") = 2
>
then this will change the value if Session("ID") for the first
user...
>
What I want is to have different ID's for each user...
>
Can someone elxplain what is wrong?
>
Thanks...
>


You must be doing something else in your code that you haven't shown, or you
are using another Browser window from the same session, because this is
definitely *not* the expected behavior.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"Flurry" wrote:

Quote:

Originally Posted by

Hello...
>
I have a simple problem...when I create a session variable as such:
>
Session("ID") = 1
>
and read this varaible from time to time...
>
The problem is that it is shared by all users not just the user that
created the session variable...
>
That is, if another user logs on and sets
>
Session("ID") = 2
>
then this will change the value if Session("ID") for the first
user...
>
What I want is to have different ID's for each user...
>
Can someone elxplain what is wrong?
>
Thanks...
>
>


Hello and thank you both for your reply...

This is strange...the code is very simple...I have two aspx pages:-

Page 1 has the following code

System.Web.HttpContext.Current.Session ("Country" ) = countryCode
server.transfer("FOTrans.aspx")

FOTrans.aspx just reads the country code as follows...

countryCode = System.Web.HttpContext.Current.Session("country")

However, as I said before the session variable is shared between
users. I have just tried logging on using two different PC's and the
problem exists. If I set Session("Country") to USA on the first pc
then set it to UK in the second pc, the first pc reads UK not USA...

Any ideas as to what could be wrong?

Thanks...
re:
!System.Web.HttpContext.Current.Session ("Country" ) = countryCode

Where dos the value for countryCode come from ?

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
======================================
"Flurry" <cj406168@.stmail.staffs.ac.ukwrote in message news:1189430823.328225.66540@.57g2000hsv.googlegrou ps.com...

Quote:

Originally Posted by

Hello and thank you both for your reply...
>
This is strange...the code is very simple...I have two aspx pages:-
>
Page 1 has the following code
>
System.Web.HttpContext.Current.Session ("Country" ) = countryCode
server.transfer("FOTrans.aspx")
>
FOTrans.aspx just reads the country code as follows...
>
countryCode = System.Web.HttpContext.Current.Session("country")
>
However, as I said before the session variable is shared between
users. I have just tried logging on using two different PC's and the
problem exists. If I set Session("Country") to USA on the first pc
then set it to UK in the second pc, the first pc reads UK not USA...
>
Any ideas as to what could be wrong?
>
Thanks...
>
>
>


Thanks for your replies...however, I've discovered my mistake...I'm
using a shared variable to hold the Session("Country") e.g.

Shared countryCode as String.
CountryCode = Session("Country")

I was using the shred variable as a global variable...I just didn't
realise that shared variables have scope outside their own session.
This is right isn't it?

Thanks for your help...
"Flurry" <cj406168@.stmail.staffs.ac.ukwrote in message
news:1189433300.687467.258850@.50g2000hsm.googlegro ups.com...

Quote:

Originally Posted by

Thanks for your replies...however, I've discovered my mistake...I'm
using a shared variable to hold the Session("Country") e.g.
>
Shared countryCode as String.
CountryCode = Session("Country")
>
I was using the shared variable as a global variable...I just didn't
realise that shared variables have scope outside their own session.
This is right isn't it?


Yes it is. Shared variables in ASP.NET need *extremely* careful
management...

Avoid them if you can...

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
re:
!shared variables have scope outside their own session.
!This is right isn't it?

Exactly, and that is why I asked where that value came from.
I suspected you were setting a global variable.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
======================================
"Flurry" <cj406168@.stmail.staffs.ac.ukwrote in message news:1189433300.687467.258850@.50g2000hsm.googlegro ups.com...

Quote:

Originally Posted by

Thanks for your replies...however, I've discovered my mistake...I'm
using a shared variable to hold the Session("Country") e.g.
>
Shared countryCode as String.
CountryCode = Session("Country")
>
I was using the shred variable as a global variable...I just didn't
realise that shared variables have scope outside their own session.
This is right isn't it?
>
Thanks for your help...
>
>

Monday, March 26, 2012

session variable issue?

I have a function that is called when the user clicks the submit button,
during this function i also set a varaible to "Y" due to that this function
does a post back to the page then redirects. When I look for the session
variable in the page.isPostBack section it equals nothing, it appears that
the variable is not being passed to the post back section correctly. I have
this due to I only want this function to run if the user has something
selected in the grid.
code:
if checkbox.checked.tostring() = true then
dim cars as string = session("selection")
cars = "Y"
end if
in the post back
if page.isPostback
if session("selection") = "Y" then 'this equals nothing I debugged it and
its getting set in the function but being passed as NOTHING
run Function
end if
end ifYou are never assigning Session("Selection") to anything.
You are setting the string "cars" to 'Y', but since never assign the Session
it will not work the way you want. I can give a more detailed explaination
if you need one, but for now reverse your code like so:
'do not call .ToString() on this, just use the bool value checkd
if checkbox.checked = true then
dim cars as string
cars = "Y"
Session("selection") = cars
end if
Then you code on the next page will work as you are hoping for it to work.
bill
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:3C57CB24-247E-433D-8971-D2E4E7CE3859@.microsoft.com...
> I have a function that is called when the user clicks the submit button,
> during this function i also set a varaible to "Y" due to that this
function
> does a post back to the page then redirects. When I look for the session
> variable in the page.isPostBack section it equals nothing, it appears
that
> the variable is not being passed to the post back section correctly. I
have
> this due to I only want this function to run if the user has something
> selected in the grid.
> code:
> if checkbox.checked.tostring() = true then
> dim cars as string = session("selection")
> cars = "Y"
> end if
> in the post back
> if page.isPostback
> if session("selection") = "Y" then 'this equals nothing I debugged it
and
> its getting set in the function but being passed as NOTHING
> run Function
> end if
> end if
>
>
I made the change you requested but i'm still having the same issue?
the session varaible is coming back blank
on the page where i'm setting the variable.
sub page_load
if page.ispostback then
if session("selection") = "Y" then 'this is sitll coming back as
nothing
response.write("You selected the following" & " " & cars)
end if
end if
im the button click routine
if CurrentCheckBox.Checked = True Then
Dim cars As String
selectedCars= "Y"
Session("selection") = selectedCars
End If
"William F. Robertson, Jr." wrote:

> You are never assigning Session("Selection") to anything.
> You are setting the string "cars" to 'Y', but since never assign the Sessi
on
> it will not work the way you want. I can give a more detailed explainatio
n
> if you need one, but for now reverse your code like so:
> 'do not call .ToString() on this, just use the bool value checkd
> if checkbox.checked = true then
> dim cars as string
> cars = "Y"
> Session("selection") = cars
> end if
> Then you code on the next page will work as you are hoping for it to work.
> bill
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:3C57CB24-247E-433D-8971-D2E4E7CE3859@.microsoft.com...
> function
> that
> have
> and
>
>
Mike,
Are these code snippets on the same page? If so, then it will not work this
way. The Button click event is fired after Page_Load. So the session will
be Nothing as it has not been set yet. Typically you would show action is
response to a Button Click event, or you can just check the CheckBox
directly in page load, depending on what else you have going during your
page execution.
If the code is on two different pages, how are you transfering the user to
the other page. Response.Redirect, Server.Transfer, Execute?
bill
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:29FB60B4-3881-49A2-8AAB-0A00B4FD907A@.microsoft.com...
> I made the change you requested but i'm still having the same issue?
> the session varaible is coming back blank
> on the page where i'm setting the variable.
> sub page_load
> if page.ispostback then
> if session("selection") = "Y" then 'this is sitll coming back as
> nothing
> response.write("You selected the following" & " " & cars)
> end if
> end if
> im the button click routine
> if CurrentCheckBox.Checked = True Then
> Dim cars As String
> selectedCars= "Y"
> Session("selection") = selectedCars
> End If
>
> "William F. Robertson, Jr." wrote:
>
Session
explaination
work.
button,
session
it
they are on the same page for the reason being that I need to post back to
myself to get the users selection from the datalist, then pass only the item
s
selected to the detail page via a querystring. ( in which i'm also have an
issue with in .NET with this particular one.)
here is the button code snippet
For I = 0 To datalist.Items.Count - 1
checkBox= dlScores.Items(I).FindControl("chkCars")
carMake= dlScores.Items(I).FindControl("carmake")
cbValue = cbValue & checkbox.Checked.ToString()
If checkbox.Checked.ToString = True Then
carMake= carMake & carmake.Text.ToString() & "|"
End If
Next
response.redirect("cardetails.aspx?car=" & carMake)
this is the function that loops thru the datalist and gets me all the cars
selected then pass only them to the detail page.
Is there an easier way to do this? I only want this to fire when the button
is clicked by the user. Also with the querystring if i have the string
seperated with | it will not work, even if i split the string. though it wil
l
work if i remove the | and only select one car in the datalist
"William F. Robertson, Jr." wrote:

> Mike,
> Are these code snippets on the same page? If so, then it will not work th
is
> way. The Button click event is fired after Page_Load. So the session wil
l
> be Nothing as it has not been set yet. Typically you would show action is
> response to a Button Click event, or you can just check the CheckBox
> directly in page load, depending on what else you have going during your
> page execution.
> If the code is on two different pages, how are you transfering the user to
> the other page. Response.Redirect, Server.Transfer, Execute?
> bill
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:29FB60B4-3881-49A2-8AAB-0A00B4FD907A@.microsoft.com...
> Session
> explaination
> work.
> button,
> session
> it
>
>
I am guessing you did not set Option Explicit On on the top of of your code.
Without strongly typed variable definitions, and I not sure what type your
variables are.
is cbValue a checkbox or a bool?
what exactly does this line do? or rather, what should it do.
carMake= carMake & carmake.Text.ToString() & "|"
is carMake a string, or a text box.
Here is a link for the option explicit on MS site. I would HIGHLY
recommend, as would most posters on this newgroup, setting this.
http://msdn.microsoft.com/library/d...ionExplicit.asp
Try using Server.UrlEncode, the pipe character might have some special
meaning through a querystring. ie
Response.Redirect( "cardetails.aspx?car=" + Server.UrlEncode( carMake ) )
bill
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:37C0264E-3BAA-44EC-8926-577F8099F5DA@.microsoft.com...
> they are on the same page for the reason being that I need to post back to
> myself to get the users selection from the datalist, then pass only the
items
> selected to the detail page via a querystring. ( in which i'm also have an
> issue with in .NET with this particular one.)
> here is the button code snippet
> For I = 0 To datalist.Items.Count - 1
> checkBox= dlScores.Items(I).FindControl("chkCars")
> carMake= dlScores.Items(I).FindControl("carmake")
> cbValue = cbValue & checkbox.Checked.ToString()
> If checkbox.Checked.ToString = True Then
> carMake= carMake & carmake.Text.ToString() & "|"
> End If
> Next
> response.redirect("cardetails.aspx?car=" & carMake)
> this is the function that loops thru the datalist and gets me all the cars
> selected then pass only them to the detail page.
> Is there an easier way to do this? I only want this to fire when the
button
> is clicked by the user. Also with the querystring if i have the string
> seperated with | it will not work, even if i split the string. though it
will
> work if i remove the | and only select one car in the datalist
>
> "William F. Robertson, Jr." wrote:
>
this
will
is
to
as
appears
correctly. I
something
debugged
Just something I noticed Mike. You are doing a redirect, but then you
handling code in inside a "ispostback" block. If you do a redirect, even if
it's to the same page you are on, then ispostback is false.
If I misunderstood you then I apologize.
Paul Ross
Hebco, Inc.
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:37C0264E-3BAA-44EC-8926-577F8099F5DA@.microsoft.com...
> they are on the same page for the reason being that I need to post back to
> myself to get the users selection from the datalist, then pass only the
> items
> selected to the detail page via a querystring. ( in which i'm also have an
> issue with in .NET with this particular one.)
> here is the button code snippet
> For I = 0 To datalist.Items.Count - 1
> checkBox= dlScores.Items(I).FindControl("chkCars")
> carMake= dlScores.Items(I).FindControl("carmake")
> cbValue = cbValue & checkbox.Checked.ToString()
> If checkbox.Checked.ToString = True Then
> carMake= carMake & carmake.Text.ToString() & "|"
> End If
> Next
> response.redirect("cardetails.aspx?car=" & carMake)
> this is the function that loops thru the datalist and gets me all the cars
> selected then pass only them to the detail page.
> Is there an easier way to do this? I only want this to fire when the
> button
> is clicked by the user. Also with the querystring if i have the string
> seperated with | it will not work, even if i split the string. though it
> will
> work if i remove the | and only select one car in the datalist
>
> "William F. Robertson, Jr." wrote:
>

session variable issue?

I have a function that is called when the user clicks the submit button,
during this function i also set a varaible to "Y" due to that this function
does a post back to the page then redirects. When I look for the session
variable in the page.isPostBack section it equals nothing, it appears that
the variable is not being passed to the post back section correctly. I have
this due to I only want this function to run if the user has something
selected in the grid.

code:
if checkbox.checked.tostring() = true then
dim cars as string = session("selection")
cars = "Y"
end if

in the post back
if page.isPostback
if session("selection") = "Y" then 'this equals nothing I debugged it and
its getting set in the function but being passed as NOTHING
run Function
end if
end ifYou are never assigning Session("Selection") to anything.

You are setting the string "cars" to 'Y', but since never assign the Session
it will not work the way you want. I can give a more detailed explaination
if you need one, but for now reverse your code like so:

'do not call .ToString() on this, just use the bool value checkd
if checkbox.checked = true then
dim cars as string
cars = "Y"
Session("selection") = cars
end if

Then you code on the next page will work as you are hoping for it to work.

bill

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:3C57CB24-247E-433D-8971-D2E4E7CE3859@.microsoft.com...
> I have a function that is called when the user clicks the submit button,
> during this function i also set a varaible to "Y" due to that this
function
> does a post back to the page then redirects. When I look for the session
> variable in the page.isPostBack section it equals nothing, it appears
that
> the variable is not being passed to the post back section correctly. I
have
> this due to I only want this function to run if the user has something
> selected in the grid.
> code:
> if checkbox.checked.tostring() = true then
> dim cars as string = session("selection")
> cars = "Y"
> end if
> in the post back
> if page.isPostback
> if session("selection") = "Y" then 'this equals nothing I debugged it
and
> its getting set in the function but being passed as NOTHING
> run Function
> end if
> end if
I made the change you requested but i'm still having the same issue?

the session varaible is coming back blank

on the page where i'm setting the variable.
sub page_load
if page.ispostback then
if session("selection") = "Y" then 'this is sitll coming back as
nothing
response.write("You selected the following" & " " & cars)
end if
end if

im the button click routine
if CurrentCheckBox.Checked = True Then
Dim cars As String
selectedCars= "Y"
Session("selection") = selectedCars
End If

"William F. Robertson, Jr." wrote:

> You are never assigning Session("Selection") to anything.
> You are setting the string "cars" to 'Y', but since never assign the Session
> it will not work the way you want. I can give a more detailed explaination
> if you need one, but for now reverse your code like so:
> 'do not call .ToString() on this, just use the bool value checkd
> if checkbox.checked = true then
> dim cars as string
> cars = "Y"
> Session("selection") = cars
> end if
> Then you code on the next page will work as you are hoping for it to work.
> bill
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:3C57CB24-247E-433D-8971-D2E4E7CE3859@.microsoft.com...
> > I have a function that is called when the user clicks the submit button,
> > during this function i also set a varaible to "Y" due to that this
> function
> > does a post back to the page then redirects. When I look for the session
> > variable in the page.isPostBack section it equals nothing, it appears
> that
> > the variable is not being passed to the post back section correctly. I
> have
> > this due to I only want this function to run if the user has something
> > selected in the grid.
> > code:
> > if checkbox.checked.tostring() = true then
> > dim cars as string = session("selection")
> > cars = "Y"
> > end if
> > in the post back
> > if page.isPostback
> > if session("selection") = "Y" then 'this equals nothing I debugged it
> and
> > its getting set in the function but being passed as NOTHING
> > run Function
> > end if
> > end if
>
Mike,

Are these code snippets on the same page? If so, then it will not work this
way. The Button click event is fired after Page_Load. So the session will
be Nothing as it has not been set yet. Typically you would show action is
response to a Button Click event, or you can just check the CheckBox
directly in page load, depending on what else you have going during your
page execution.

If the code is on two different pages, how are you transfering the user to
the other page. Response.Redirect, Server.Transfer, Execute?

bill

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:29FB60B4-3881-49A2-8AAB-0A00B4FD907A@.microsoft.com...
> I made the change you requested but i'm still having the same issue?
> the session varaible is coming back blank
> on the page where i'm setting the variable.
> sub page_load
> if page.ispostback then
> if session("selection") = "Y" then 'this is sitll coming back as
> nothing
> response.write("You selected the following" & " " & cars)
> end if
> end if
> im the button click routine
> if CurrentCheckBox.Checked = True Then
> Dim cars As String
> selectedCars= "Y"
> Session("selection") = selectedCars
> End If
>
> "William F. Robertson, Jr." wrote:
> > You are never assigning Session("Selection") to anything.
> > You are setting the string "cars" to 'Y', but since never assign the
Session
> > it will not work the way you want. I can give a more detailed
explaination
> > if you need one, but for now reverse your code like so:
> > 'do not call .ToString() on this, just use the bool value checkd
> > if checkbox.checked = true then
> > dim cars as string
> > cars = "Y"
> > Session("selection") = cars
> > end if
> > Then you code on the next page will work as you are hoping for it to
work.
> > bill
> > "Mike" <Mike@.discussions.microsoft.com> wrote in message
> > news:3C57CB24-247E-433D-8971-D2E4E7CE3859@.microsoft.com...
> > > I have a function that is called when the user clicks the submit
button,
> > > during this function i also set a varaible to "Y" due to that this
> > function
> > > does a post back to the page then redirects. When I look for the
session
> > > variable in the page.isPostBack section it equals nothing, it appears
> > that
> > > the variable is not being passed to the post back section correctly. I
> > have
> > > this due to I only want this function to run if the user has something
> > > selected in the grid.
> > > > code:
> > > if checkbox.checked.tostring() = true then
> > > dim cars as string = session("selection")
> > > cars = "Y"
> > > end if
> > > > in the post back
> > > if page.isPostback
> > > if session("selection") = "Y" then 'this equals nothing I debugged
it
> > and
> > > its getting set in the function but being passed as NOTHING
> > > run Function
> > > end if
> > > end if
> > >
they are on the same page for the reason being that I need to post back to
myself to get the users selection from the datalist, then pass only the items
selected to the detail page via a querystring. ( in which i'm also have an
issue with in .NET with this particular one.)

here is the button code snippet
For I = 0 To datalist.Items.Count - 1
checkBox= dlScores.Items(I).FindControl("chkCars")
carMake= dlScores.Items(I).FindControl("carmake")
cbValue = cbValue & checkbox.Checked.ToString()
If checkbox.Checked.ToString = True Then
carMake= carMake & carmake.Text.ToString() & "|"
End If
Next
response.redirect("cardetails.aspx?car=" & carMake)

this is the function that loops thru the datalist and gets me all the cars
selected then pass only them to the detail page.

Is there an easier way to do this? I only want this to fire when the button
is clicked by the user. Also with the querystring if i have the string
seperated with | it will not work, even if i split the string. though it will
work if i remove the | and only select one car in the datalist

"William F. Robertson, Jr." wrote:

> Mike,
> Are these code snippets on the same page? If so, then it will not work this
> way. The Button click event is fired after Page_Load. So the session will
> be Nothing as it has not been set yet. Typically you would show action is
> response to a Button Click event, or you can just check the CheckBox
> directly in page load, depending on what else you have going during your
> page execution.
> If the code is on two different pages, how are you transfering the user to
> the other page. Response.Redirect, Server.Transfer, Execute?
> bill
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:29FB60B4-3881-49A2-8AAB-0A00B4FD907A@.microsoft.com...
> > I made the change you requested but i'm still having the same issue?
> > the session varaible is coming back blank
> > on the page where i'm setting the variable.
> > sub page_load
> > if page.ispostback then
> > if session("selection") = "Y" then 'this is sitll coming back as
> > nothing
> > response.write("You selected the following" & " " & cars)
> > end if
> > end if
> > im the button click routine
> > if CurrentCheckBox.Checked = True Then
> > Dim cars As String
> > selectedCars= "Y"
> > Session("selection") = selectedCars
> > End If
> > "William F. Robertson, Jr." wrote:
> > > You are never assigning Session("Selection") to anything.
> > > > You are setting the string "cars" to 'Y', but since never assign the
> Session
> > > it will not work the way you want. I can give a more detailed
> explaination
> > > if you need one, but for now reverse your code like so:
> > > > 'do not call .ToString() on this, just use the bool value checkd
> > > if checkbox.checked = true then
> > > dim cars as string
> > > cars = "Y"
> > > Session("selection") = cars
> > > end if
> > > > Then you code on the next page will work as you are hoping for it to
> work.
> > > > bill
> > > > "Mike" <Mike@.discussions.microsoft.com> wrote in message
> > > news:3C57CB24-247E-433D-8971-D2E4E7CE3859@.microsoft.com...
> > > > I have a function that is called when the user clicks the submit
> button,
> > > > during this function i also set a varaible to "Y" due to that this
> > > function
> > > > does a post back to the page then redirects. When I look for the
> session
> > > > variable in the page.isPostBack section it equals nothing, it appears
> > > that
> > > > the variable is not being passed to the post back section correctly. I
> > > have
> > > > this due to I only want this function to run if the user has something
> > > > selected in the grid.
> > > > > > code:
> > > > if checkbox.checked.tostring() = true then
> > > > dim cars as string = session("selection")
> > > > cars = "Y"
> > > > end if
> > > > > > in the post back
> > > > if page.isPostback
> > > > if session("selection") = "Y" then 'this equals nothing I debugged
> it
> > > and
> > > > its getting set in the function but being passed as NOTHING
> > > > run Function
> > > > end if
> > > > end if
> > > > > > > > > >
I am guessing you did not set Option Explicit On on the top of of your code.
Without strongly typed variable definitions, and I not sure what type your
variables are.

is cbValue a checkbox or a bool?
what exactly does this line do? or rather, what should it do.
carMake= carMake & carmake.Text.ToString() & "|"

is carMake a string, or a text box.

Here is a link for the option explicit on MS site. I would HIGHLY
recommend, as would most posters on this newgroup, setting this.
http://msdn.microsoft.com/library/d...ionExplicit.asp

Try using Server.UrlEncode, the pipe character might have some special
meaning through a querystring. ie

Response.Redirect( "cardetails.aspx?car=" + Server.UrlEncode( carMake ) )

bill

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:37C0264E-3BAA-44EC-8926-577F8099F5DA@.microsoft.com...
> they are on the same page for the reason being that I need to post back to
> myself to get the users selection from the datalist, then pass only the
items
> selected to the detail page via a querystring. ( in which i'm also have an
> issue with in .NET with this particular one.)
> here is the button code snippet
> For I = 0 To datalist.Items.Count - 1
> checkBox= dlScores.Items(I).FindControl("chkCars")
> carMake= dlScores.Items(I).FindControl("carmake")
> cbValue = cbValue & checkbox.Checked.ToString()
> If checkbox.Checked.ToString = True Then
> carMake= carMake & carmake.Text.ToString() & "|"
> End If
> Next
> response.redirect("cardetails.aspx?car=" & carMake)
> this is the function that loops thru the datalist and gets me all the cars
> selected then pass only them to the detail page.
> Is there an easier way to do this? I only want this to fire when the
button
> is clicked by the user. Also with the querystring if i have the string
> seperated with | it will not work, even if i split the string. though it
will
> work if i remove the | and only select one car in the datalist
>
> "William F. Robertson, Jr." wrote:
> > Mike,
> > Are these code snippets on the same page? If so, then it will not work
this
> > way. The Button click event is fired after Page_Load. So the session
will
> > be Nothing as it has not been set yet. Typically you would show action
is
> > response to a Button Click event, or you can just check the CheckBox
> > directly in page load, depending on what else you have going during your
> > page execution.
> > If the code is on two different pages, how are you transfering the user
to
> > the other page. Response.Redirect, Server.Transfer, Execute?
> > bill
> > "Mike" <Mike@.discussions.microsoft.com> wrote in message
> > news:29FB60B4-3881-49A2-8AAB-0A00B4FD907A@.microsoft.com...
> > > I made the change you requested but i'm still having the same issue?
> > > > the session varaible is coming back blank
> > > > on the page where i'm setting the variable.
> > > sub page_load
> > > if page.ispostback then
> > > if session("selection") = "Y" then 'this is sitll coming back
as
> > > nothing
> > > response.write("You selected the following" & " " & cars)
> > > end if
> > > end if
> > > > im the button click routine
> > > if CurrentCheckBox.Checked = True Then
> > > Dim cars As String
> > > selectedCars= "Y"
> > > Session("selection") = selectedCars
> > > End If
> > > > > > "William F. Robertson, Jr." wrote:
> > > > > You are never assigning Session("Selection") to anything.
> > > > > > You are setting the string "cars" to 'Y', but since never assign the
> > Session
> > > > it will not work the way you want. I can give a more detailed
> > explaination
> > > > if you need one, but for now reverse your code like so:
> > > > > > 'do not call .ToString() on this, just use the bool value checkd
> > > > if checkbox.checked = true then
> > > > dim cars as string
> > > > cars = "Y"
> > > > Session("selection") = cars
> > > > end if
> > > > > > Then you code on the next page will work as you are hoping for it to
> > work.
> > > > > > bill
> > > > > > "Mike" <Mike@.discussions.microsoft.com> wrote in message
> > > > news:3C57CB24-247E-433D-8971-D2E4E7CE3859@.microsoft.com...
> > > > > I have a function that is called when the user clicks the submit
> > button,
> > > > > during this function i also set a varaible to "Y" due to that this
> > > > function
> > > > > does a post back to the page then redirects. When I look for the
> > session
> > > > > variable in the page.isPostBack section it equals nothing, it
appears
> > > > that
> > > > > the variable is not being passed to the post back section
correctly. I
> > > > have
> > > > > this due to I only want this function to run if the user has
something
> > > > > selected in the grid.
> > > > > > > > code:
> > > > > if checkbox.checked.tostring() = true then
> > > > > dim cars as string = session("selection")
> > > > > cars = "Y"
> > > > > end if
> > > > > > > > in the post back
> > > > > if page.isPostback
> > > > > if session("selection") = "Y" then 'this equals nothing I
debugged
> > it
> > > > and
> > > > > its getting set in the function but being passed as NOTHING
> > > > > run Function
> > > > > end if
> > > > > end if
> > > > > > > > > > > > > > >
Just something I noticed Mike. You are doing a redirect, but then you
handling code in inside a "ispostback" block. If you do a redirect, even if
it's to the same page you are on, then ispostback is false.

If I misunderstood you then I apologize.

Paul Ross
Hebco, Inc.

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:37C0264E-3BAA-44EC-8926-577F8099F5DA@.microsoft.com...
> they are on the same page for the reason being that I need to post back to
> myself to get the users selection from the datalist, then pass only the
> items
> selected to the detail page via a querystring. ( in which i'm also have an
> issue with in .NET with this particular one.)
> here is the button code snippet
> For I = 0 To datalist.Items.Count - 1
> checkBox= dlScores.Items(I).FindControl("chkCars")
> carMake= dlScores.Items(I).FindControl("carmake")
> cbValue = cbValue & checkbox.Checked.ToString()
> If checkbox.Checked.ToString = True Then
> carMake= carMake & carmake.Text.ToString() & "|"
> End If
> Next
> response.redirect("cardetails.aspx?car=" & carMake)
> this is the function that loops thru the datalist and gets me all the cars
> selected then pass only them to the detail page.
> Is there an easier way to do this? I only want this to fire when the
> button
> is clicked by the user. Also with the querystring if i have the string
> seperated with | it will not work, even if i split the string. though it
> will
> work if i remove the | and only select one car in the datalist
>
> "William F. Robertson, Jr." wrote:
>> Mike,
>>
>> Are these code snippets on the same page? If so, then it will not work
>> this
>> way. The Button click event is fired after Page_Load. So the session
>> will
>> be Nothing as it has not been set yet. Typically you would show action
>> is
>> response to a Button Click event, or you can just check the CheckBox
>> directly in page load, depending on what else you have going during your
>> page execution.
>>
>> If the code is on two different pages, how are you transfering the user
>> to
>> the other page. Response.Redirect, Server.Transfer, Execute?
>>
>> bill
>>
>> "Mike" <Mike@.discussions.microsoft.com> wrote in message
>> news:29FB60B4-3881-49A2-8AAB-0A00B4FD907A@.microsoft.com...
>> > I made the change you requested but i'm still having the same issue?
>>> > the session varaible is coming back blank
>>> > on the page where i'm setting the variable.
>> > sub page_load
>> > if page.ispostback then
>> > if session("selection") = "Y" then 'this is sitll coming back
>> > as
>> > nothing
>> > response.write("You selected the following" & " " & cars)
>> > end if
>> > end if
>>> > im the button click routine
>> > if CurrentCheckBox.Checked = True Then
>> > Dim cars As String
>> > selectedCars= "Y"
>> > Session("selection") = selectedCars
>> > End If
>>>>> > "William F. Robertson, Jr." wrote:
>>> > > You are never assigning Session("Selection") to anything.
>> >> > > You are setting the string "cars" to 'Y', but since never assign the
>> Session
>> > > it will not work the way you want. I can give a more detailed
>> explaination
>> > > if you need one, but for now reverse your code like so:
>> >> > > 'do not call .ToString() on this, just use the bool value checkd
>> > > if checkbox.checked = true then
>> > > dim cars as string
>> > > cars = "Y"
>> > > Session("selection") = cars
>> > > end if
>> >> > > Then you code on the next page will work as you are hoping for it to
>> work.
>> >> > > bill
>> >> > > "Mike" <Mike@.discussions.microsoft.com> wrote in message
>> > > news:3C57CB24-247E-433D-8971-D2E4E7CE3859@.microsoft.com...
>> > > > I have a function that is called when the user clicks the submit
>> button,
>> > > > during this function i also set a varaible to "Y" due to that this
>> > > function
>> > > > does a post back to the page then redirects. When I look for the
>> session
>> > > > variable in the page.isPostBack section it equals nothing, it
>> > > > appears
>> > > that
>> > > > the variable is not being passed to the post back section
>> > > > correctly. I
>> > > have
>> > > > this due to I only want this function to run if the user has
>> > > > something
>> > > > selected in the grid.
>> > >> > > > code:
>> > > > if checkbox.checked.tostring() = true then
>> > > > dim cars as string = session("selection")
>> > > > cars = "Y"
>> > > > end if
>> > >> > > > in the post back
>> > > > if page.isPostback
>> > > > if session("selection") = "Y" then 'this equals nothing I
>> > > > debugged
>> it
>> > > and
>> > > > its getting set in the function but being passed as NOTHING
>> > > > run Function
>> > > > end if
>> > > > end if
>> > >> > >> > >> >> >> >>
>>
>