473,769 Members | 7,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ViewState and Javascript.

Is it possible to interact with the ASP.NET ViewState using JavaScript? I
would like to be able to access data in ViewState through JavaScript and
also set ViewState data. Not sure if this is the "best:" way to send data
between ASP.NET pages and JavaScript. If anyone has other suggestions,
please feel free to comment.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
Nov 18 '05 #1
5 19725
ViewState is encrypted, so I don't think you would really be able to
retrieve data from it.
You can write out javascript that has your client side variables from the
server, to get those values over.

"Ken Varn" <nospam> wrote in message
news:ut******** ******@TK2MSFTN GP11.phx.gbl...
Is it possible to interact with the ASP.NET ViewState using JavaScript? I
would like to be able to access data in ViewState through JavaScript and
also set ViewState data. Not sure if this is the "best:" way to send data
between ASP.NET pages and JavaScript. If anyone has other suggestions,
please feel free to comment.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------

Nov 18 '05 #2
Hi, Ken

The simplest way is to define the variale as a hidden field runat server
<input type="hidden" runat="server" id="hidValue"/
Then you can access the value both in JavaScript and Code Behind

Bin Song, MC

----- Ken Varn wrote: ----

Is it possible to interact with the ASP.NET ViewState using JavaScript?
would like to be able to access data in ViewState through JavaScript an
also set ViewState data. Not sure if this is the "best:" way to send dat
between ASP.NET pages and JavaScript. If anyone has other suggestions
please feel free to comment

--
----------------------------------
Ken Var
Senior Software Enginee
Diebold Inc

EmailID = varn
Domain = Diebold.co
----------------------------------

Nov 18 '05 #3
You could interact with ViewState, but I'd advise against doing so.

The ViewState holds data about the page and the page's controls for
use by the server, it's not designed as a communication mechanism
between client and server (in fact, ViewState is MAC encoded by
default to prevent tampering by the client).

You can certainly create your own hidden fields however and use them
to pass values back and forth, i.e:

<INPUT id="myfield" type="hidden" value="blah" runat="server">

which from the code behind will be of type
System.Web.UI.H tmlControls.Htm lInputHidden.

HTH,

--
Scott
http://www.OdeToCode.com
On Tue, 13 Apr 2004 08:58:20 -0400, "Ken Varn" <nospam> wrote:
Is it possible to interact with the ASP.NET ViewState using JavaScript? I
would like to be able to access data in ViewState through JavaScript and
also set ViewState data. Not sure if this is the "best:" way to send data
between ASP.NET pages and JavaScript. If anyone has other suggestions,
please feel free to comment.


Nov 18 '05 #4
Ken,

I believe ViewState information is Base64 encoded, so as long as you can
decode it in JavaScript, you shouldn't have a problem accessing the
decrypted form element information, although I've never tried it.

HTH,

Raymond Lewallen

"Ken Varn" <nospam> wrote in message
news:ut******** ******@TK2MSFTN GP11.phx.gbl...
Is it possible to interact with the ASP.NET ViewState using JavaScript? I
would like to be able to access data in ViewState through JavaScript and
also set ViewState data. Not sure if this is the "best:" way to send data
between ASP.NET pages and JavaScript. If anyone has other suggestions,
please feel free to comment.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------

Nov 18 '05 #5
It is also compressed.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Raymond Lewallen" <Ra************ ******@nospam.f aa.gov> wrote in message
news:Os******** ******@TK2MSFTN GP12.phx.gbl...
Ken,

I believe ViewState information is Base64 encoded, so as long as you can
decode it in JavaScript, you shouldn't have a problem accessing the
decrypted form element information, although I've never tried it.

HTH,

Raymond Lewallen

"Ken Varn" <nospam> wrote in message
news:ut******** ******@TK2MSFTN GP11.phx.gbl...
Is it possible to interact with the ASP.NET ViewState using JavaScript? I would like to be able to access data in ViewState through JavaScript and
also set ViewState data. Not sure if this is the "best:" way to send data between ASP.NET pages and JavaScript. If anyone has other suggestions,
please feel free to comment.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------


Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1666
by: David Anderson | last post by:
I'm having trouble persisting viewstate information for webcontrols I've disabled via javascript. I have a group of textboxes that I enable/disable via a checkbox control that invokes a javascript method in its onclick attribute. When the page does a postsback, the textboxes that are enabled have their viewstate persisted; however, the ones that are disabled (but still have text in them) do not have their viewstate persisted. I have...
1
1230
by: Jeremy Ames | last post by:
Ok, I was wrong. It pains me to say that, but it does happen occasionally. LOL It is not actually a Server.Transfer that is causing that problem but some javascript that I have tied to some hyperlinks. I have created the hyperlinks at run time and attached them to a piece of javascript that changes a value and then submits the form. Since noticing the cause of the problem I have tried addind event handlers to the hyper links, but they do...
9
21651
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter the results in the grid. Say you filter the grid for records that have a certain condition set to "NO" (in this case a checkbox). In this scenario the search returns one result. If I then check the checkbox ("YES") and save it, I now get my message...
3
2651
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event and this causes control B to be created, when this is done the VIEWSTATE is lost for CONTROL B. In the EVENT that causes CONTROL B to be created I have to set
2
3199
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp The problem I am having is that the data in the custom datagridcolumn is not saved to viewstate and after postback, the column does not contain data.
5
1609
by: Ken Varn | last post by:
Is it possible to interact with the ASP.NET ViewState using JavaScript? I would like to be able to access data in ViewState through JavaScript and also set ViewState data. Not sure if this is the "best:" way to send data between ASP.NET pages and JavaScript. If anyone has other suggestions, please feel free to comment. -- ----------------------------------- Ken Varn Senior Software Engineer
1
1970
by: Mind Dragon | last post by:
I have an ASP application that works fine locally but when it's uploaded occasionally, I get viewstate errors. Another thing is that the viewstate for that page is disabled. There are cases where I can just refresh the page and it goes through ok <%@ Page Language="VB" EnableViewState="false" Debug="true" % The worker threads are set to one, however, it is running on a dual processor web server. The Load Balancer is not installed. What...
1
2344
by: batista | last post by:
Hello, I have a web page, which is being refresh after every 30 secs.Now, there is also a datagrid in it, which i bind in the pageload event. Now the problem is when the page is refresh after 30 secs the datagrid loses it's values. I mean it does not maintain it's viewstate. Why is it?
10
3092
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web config does specify a machinekey setting: <machineKey validationKey="447C05E8B3A71401CC4CAE5513A7F1A3494A3618EE819316AAD1D58433F236A759D66FB4154500E01EB4E1BC1DE42046E2D652D391CB8367A1649438867A02EB"...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10048
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.