473,320 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 19700
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**************@TK2MSFTNGP11.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.HtmlControls.HtmlInputHidden.

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**************@TK2MSFTNGP11.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.faa.gov> wrote in message
news:Os**************@TK2MSFTNGP12.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**************@TK2MSFTNGP11.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
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...
1
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...
9
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...
3
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...
2
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...
5
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...
1
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...
1
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...
10
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.