ASP.NET, Javascript value modification problem 1
February 20th, 2006 // 4:02 pm @ Amar
While solving one particular case in a SharePoint webpart, I came across a very queer problem in ASP.NET Postback and Viewstate handling. Let me declare the scenario in detail :
I have a page A which has some values in hidden variables of type HtmlControls.HtmlInputHidden.
I popup a page B from page A using javascript window.open. Page B has a button called Send Mail which would send a mail to some recipients. The recipients list has to come from page A.
The standard way of passing data from one window to a javascript popup is querystring, but that is something which is not wanted. It has to work without querystring data passing, and as it is in SharePoint sessions are disabled by default, and hence passing by session is also not an option.
So the only option, is to keep a few hidden variables in page B, read the values from page A using window.opener from Javascript in page B, set the values of the hidden variables in page B, and then on click on Send Mail, access the hidden variables and send a mail using ASP.NET.
The funny problem, is that I can read the values from page A, using javascript. I can also set the values to the hidden variables ( verified by using and alert and checking the value of the hidden variable after it is set ), but as soon as I click Send Message, and try to access the value of the hidden variables from the backend ASP.NET code, the values set using Javascript are lost. On examination, the Viewstate seems to ignore the changes made to the Javascript, if the controls are hidden and does not pass it to the backend.
If the controls are like ASP.NET Textboxes, it works properly, but if they are hidden, again the same problem as above occurs. So definitely it not something exclusive for non .NET Controls.
More on this later on how I solved it when I take my next break
Posted on DotNetJunkies at Tuesday, November 09, 2004 1:12 PM
Category : dotNet
http://
5 years ago
Please help me out of this situation. I am also facing the datalose on postback.
Amar Galla
5 years ago
Check my other post : http://amargalla.com/blog/?p=14
It contains the required solution.