Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 23rd, 2013, 03:40 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to set and modify session variable using TextBox in javascript

In asp.net , I set session variable .Then pass it to javascript for modification .
In javascript I can read session variable value and return modified value in TextBox1 .
In asp.net again , I receive modified session variable value and store it in session variable .

protected void Page_Load(object sender, EventArgs e)
Session["MyTest"] = "abcd";

String csname = "OnSubmitScript";
Type cstype = this.GetType();

// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;

// Check to see if the OnSubmit statement is already registered.
if (!cs.IsOnSubmitStatementRegistered(cstype, csname))
string cstext = " document.getElementById(\"TextBox1\").value = getMyvalSession() ; ";
cs.RegisterOnSubmitStatement(cstype, csname, cstext);

if (TextBox1.Text.Equals("")) { }
else {
Session["MyTest"] = TextBox1.Text;


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

<script language=javascript type="text/javascript">
function getMyvalSession() {

var txt = "efgh";
var ff = '<%=Session["MyTest"] %>' + txt;
return ff ;


<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack=true ></asp:TextBox>
<input type="submit" value="Submit" />
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Set xsl variable using Javascript variable Kunn XSLT 5 December 31st, 2008 02:43 AM
set a asp variable with a value in Javascript crmpicco Javascript How-To 6 March 11th, 2005 11:07 AM
set a asp variable with a value in Javascript crmpicco Classic ASP Basics 3 March 10th, 2005 10:46 AM
set ASP variable values inside Javascript crmpicco HTML Code Clinic 1 March 9th, 2005 12:32 PM
Assigning Javascript variable to ASP session anaden Classic ASP Basics 2 September 18th, 2004 02:16 AM

All times are GMT -4. The time now is 09:49 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.