Home All Groups Group Topic Archive Search About

Assign Javascript value to asp session variable

Author
9 Oct 2006 6:58 AM
philin007
Hi ,

I have the following javascript codes:
******************************************
<script language="JavaScript">
<!--
....
.....
if (nextRow >5)
{
<%Session("txtTotal")=%> = nextRow;

for (var i=1; i<NewTotalRow; i++) {
<%

'session("txtBeginDT" & i) =
'session("txtEndDT" & i) = %>
}

}

....
....
// -->
</script>
******************************************
Does any one know if we can assign a javascript value to a asp session
variable?
eg [<%Session("txtTotal")=%> = nextRow; ]
is this correct ?

regards
philin

Author
9 Oct 2006 9:17 AM
Patrice
I assume this is a client side script. You won't have (at least directly)
access to session variables stored on the server when running client side
code.

A usual way to transmit client side computed values to the server is to
store them in hidden fields that will the be read server side on the next
submit (you need a server round trip whatever method you wan't to use)...

--
Patrice

<philin***@gmail.com> a écrit dans le message de news:
1160377093.128040.325***@k70g2000cwa.googlegroups.com...
Show quoteHide quote
> Hi ,
>
> I have the following javascript codes:
> ******************************************
> <script language="JavaScript">
> <!--
> ...
> ....
> if (nextRow >5)
> {
> <%Session("txtTotal")=%> = nextRow;
>
> for (var i=1; i<NewTotalRow; i++) {
> <%
>
> 'session("txtBeginDT" & i) =
> 'session("txtEndDT" & i) = %>
> }
>
> }
>
> ...
> ...
> // -->
> </script>
> ******************************************
> Does any one know if we can assign a javascript value to a asp session
> variable?
> eg [<%Session("txtTotal")=%> = nextRow; ]
> is this correct ?
>
> regards
> philin
>
Are all your drivers up to date? click for free checkup

Author
9 Oct 2006 9:17 AM
Anthony Jones
<philin***@gmail.com> wrote in message
Show quoteHide quote
news:1160377093.128040.325230@k70g2000cwa.googlegroups.com...
> Hi ,
>
> I have the following javascript codes:
> ******************************************
> <script language="JavaScript">
> <!--
> ...
> ....
> if (nextRow >5)
> {
> <%Session("txtTotal")=%> = nextRow;
>
> for (var i=1; i<NewTotalRow; i++) {
> <%
>
> 'session("txtBeginDT" & i) =
> 'session("txtEndDT" & i) = %>
> }
>
> }
>
> ...
> ...
> // -->
> </script>
> ******************************************
> Does any one know if we can assign a javascript value to a asp session
> variable?
> eg [<%Session("txtTotal")=%> = nextRow; ]
> is this correct ?
>

No.  Javascript in this case is running in the browser on the client.  It
has no access to the session object which is on the server.  Your need to
either include this value in a Form field that is submited to the server or
use another means to send the value from the client to the server.  Perhaps
the best solution is to reconsider the design and remove this requirement
all together.



Show quoteHide quote
> regards
> philin
>
Author
9 Oct 2006 9:34 AM
philin007
thanks guys..

i think i will have to use hidden fields..there are new methods like
ajax but not so familiar with it..Hidden fields the problem is the
value can be seen(right click view source) tats why I was thinkin of
using the session variable...looks like no other solution :)

Anthony Jones wrote:
Show quoteHide quote
> <philin***@gmail.com> wrote in message
> news:1160377093.128040.325230@k70g2000cwa.googlegroups.com...
> > Hi ,
> >
> > I have the following javascript codes:
> > ******************************************
> > <script language="JavaScript">
> > <!--
> > ...
> > ....
> > if (nextRow >5)
> > {
> > <%Session("txtTotal")=%> = nextRow;
> >
> > for (var i=1; i<NewTotalRow; i++) {
> > <%
> >
> > 'session("txtBeginDT" & i) =
> > 'session("txtEndDT" & i) = %>
> > }
> >
> > }
> >
> > ...
> > ...
> > // -->
> > </script>
> > ******************************************
> > Does any one know if we can assign a javascript value to a asp session
> > variable?
> > eg [<%Session("txtTotal")=%> = nextRow; ]
> > is this correct ?
> >
>
> No.  Javascript in this case is running in the browser on the client.  It
> has no access to the session object which is on the server.  Your need to
> either include this value in a Form field that is submited to the server or
> use another means to send the value from the client to the server.  Perhaps
> the best solution is to reconsider the design and remove this requirement
> all together.
>
>
>
> > regards
> > philin
> >
Author
9 Oct 2006 10:00 AM
Anthony Jones
<philin***@gmail.com> wrote in message
news:1160386471.788907.196290@k70g2000cwa.googlegroups.com...
> thanks guys..
>
> i think i will have to use hidden fields..there are new methods like
> ajax but not so familiar with it..Hidden fields the problem is the
> value can be seen(right click view source) tats why I was thinkin of
> using the session variable...looks like no other solution :)

Being able to see internal values on the client is not a real problem.
There's nothing stopping the user debugging and single stepping your code.
So if you really do have something that a user must never be able to see, a
browser based solution is not for you.


Show quoteHide quote
>
> Anthony Jones wrote:
> > <philin***@gmail.com> wrote in message
> > news:1160377093.128040.325230@k70g2000cwa.googlegroups.com...
> > > Hi ,
> > >
> > > I have the following javascript codes:
> > > ******************************************
> > > <script language="JavaScript">
> > > <!--
> > > ...
> > > ....
> > > if (nextRow >5)
> > > {
> > > <%Session("txtTotal")=%> = nextRow;
> > >
> > > for (var i=1; i<NewTotalRow; i++) {
> > > <%
> > >
> > > 'session("txtBeginDT" & i) =
> > > 'session("txtEndDT" & i) = %>
> > > }
> > >
> > > }
> > >
> > > ...
> > > ...
> > > // -->
> > > </script>
> > > ******************************************
> > > Does any one know if we can assign a javascript value to a asp session
> > > variable?
> > > eg [<%Session("txtTotal")=%> = nextRow; ]
> > > is this correct ?
> > >
> >
> > No.  Javascript in this case is running in the browser on the client.
It
> > has no access to the session object which is on the server.  Your need
to
> > either include this value in a Form field that is submited to the server
or
> > use another means to send the value from the client to the server.
Perhaps
> > the best solution is to reconsider the design and remove this
requirement
> > all together.
> >
> >
> >
> > > regards
> > > philin
> > >
>

Bookmark and Share