Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Assign Javascript value to asp session variable

Reply
Thread Tools

Assign Javascript value to asp session variable

 
 
philin007@gmail.com
Guest
Posts: n/a
 
      10-09-2006
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

 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      10-09-2006
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

<(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed). 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 ?
>
> regards
> philin
>



 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      10-09-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.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
>



 
Reply With Quote
 
philin007@gmail.com
Guest
Posts: n/a
 
      10-09-2006
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:
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.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
> >


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      10-09-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.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.


>
> Anthony Jones wrote:
> > <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) oups.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
> > >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
assign JavaScript variable to Java variable problem in JSP Matt Java 8 01-25-2010 04:48 PM
How to Assign JavaScript variable to Jsp Variable Ranjan ASP .Net 1 04-10-2007 03:35 PM
Assign a value to a Session variable from an Script Mirovk ASP General 2 08-22-2006 02:04 PM
Assign value from datagrid to a session variable Jesper Pedersen ASP .Net 3 10-24-2004 01:58 PM
assign javascript variable value to VBScript server side variable Matt ASP General 2 09-25-2004 10:40 AM



Advertisments