Hidden field client side value lost on post back


I have a checkbox list , two text box , with link to javascript calendars and two hidden fields.

The checkbox list contains years with start and end date in text part and the two textboxes are From and To date.

Initially when the page is loaded the first year in the list is checked then the hidden field for start and end date is set at server side.

After that on client side onload we run a javascript that picks up the date from hidden fields and set them on the two dates textboxex respectively in client locale.

No when i change the checkbox check the repect date in text part of the checkbox are extracted from at client side and set the hidden field and then the two dates textboxes.If i try to save now the changes made at client side are easily captured at server side and stored in database.If i change the dates using the javascript calendar(external JS file referenced in the page) for the two dates textboxes and hidden variables are reflected at server side(condition is that any of the checkbox is checkbox list has to be checked)

But if none of the checkbox is checked in the checkbox list i clear the the two date textboxes control and the hidden variable.Now if i try to set the the date textboxes using javascript calendar interm also the hidden variable the changes are not reflected at server side.

I have noticed that when i do an alert for the hidden variable its show the updated date.I have also seen the request object and can see the updated value is fetched at postbox, but when i try to access the hidden variable value it shows it empty.

I know i can get the updated value from the request object and go  one with the problem.But i need to know what is wrong with current.

Why are the changes not accessible at sever side if none of the checkbox is checked.One more thing i have checked the code and tried to access the hidden variable as first statement at page load also to avoid any cleaning of variable due to any custom code but it shows still empty.

Has anyone ever faced this issue.Please help me if you have any updates or suggestions will be greatly appreciated.

Thanks you all in advance



Aayam Singh


1/12/2009 7:24:15 AM
asp.net.client-side 24353 articles. 2 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 13

I was able to get hold of my silly mistake. The modification made by me was actually to avoid postback in checkbox list and set the date textboxes using javascript. I made these changes and removed the autopostback for checkboxlist but didnt remove the server side selectedindex change event from code behind which contained the code for clearing for Hidden field. This selected changes event for checkbox list did used to fire beacause of postback due to button. I know it was silly mistake in my part and considered to give the resolution so that it could be useful to someone. Thanks for help Regards, Aayam Singh
1/12/2009 8:03:39 AM

Similar Artilces:

Client side set hidden field value not POSTing back
 hi,(sorry, I dont have any code snippets to hand as I'm away from the dev machine at the mo)I have a page which makes two seperate WebServce calls for data. One is via an Ajax call, the other is server side.The flow is as follows:1. Ajax Web Service call returns a collection2. In the js script file, read the PK's of the collection and set a hiddenfield with the comma-seperated keys3. initiate a __doPostBack call from script - target an update panel on the page which then calls the second Web ServiceThe problem I am experiencing is that after I have made the first call and ...

Using hidden field to store value then calling that value from client side
I have three tabs (1,2,3) on my main page each tab contains a datagrid... when a user select a tab then leaves the main page and returns to that main page(without exiting browser) I need for the page to open with the tab last selected by that user so that they can pick up where they left off. No one can seem to help me with this issue.... My javascript (client side) code function is as follows: <asp:HiddenField ID="hdnNewPanel" runat="server" /> <script language="javascript" type="text/javascript"> &nb...

Passing client side to server side using hidden field
 I have a hidden asp.net text box that is being updated on the client via javascript. I am trying to determine the best way to detect when that hidden field has changed and read the new value on the server. I would like to do this WITHOUT posting back. I have tried using the TextChanged event but that requires blur state to be changed before it gets fired. What would be the best way to do this? Thanks, Justin.  Can you use __doPostBack() to trigger a partial postback at the same time the hidden TextBox is updated, from JavaScript? Encosia - ASP.NET, AJAX, and more.Lates...

Getting hidden variable value from server side in client side
hi,        I am struck in problem. I have a hidden field in my form and i am setting some value in that.         Now i wnt to use this value from client side but i m not able to retrieve it. All i am getting there is an object.         I feel the hidden field is not able to hold that value.         <input type="hidden" id="hdnVar" runat="server" />         in code behind      ...

client-side and server-side validation reducing post-backs question
For my page I was using server-side validation. In order to reduce post-backs I decided to implement client-side validation -- do the same validation as server (but keep server-side for security reasons). I could not find the answer to this easily -- Does my client-side validation stop post-backs? I've noticed that having one client-side validation does not stop the other server-validations from doing a post-back. Currently I have 5 CustomValidators, all with ClientValidationFunction and OnServerValidate set. When the client script sets args.isValid as false, does it stop the postback fr...

problem: client side validation posting back server side in firefox only
Hi I have validation controls and I only want them to validate via client side. It works in IE. But in firefox it does validate client side, however it immediately post backs server side. How can I prevent this?? I have a login control and it works fine there. Only problem it occurs is inside a createuserwizard. I have sumary validation with js pop up. Using asp.net 3.5. Before trying to solve the actual problem, please implement server side validation. Consider it a manditory part of validation because: - The user may have a browser not supported by the client-side scripts - T...

Sending array data with hidden input field from client side to server side
I have some values that I'm sending with javascript to the server side code via a hidden input field.  This works great.  However, I want to find an elegant way to split the values up on the server side.  What I have below works, but it doesn't seem like a very clean solution.  Client codevar values = '&approved=1&funded=0&winprob=2'; document.form1.ipHidden.value = values.toString(); Server codeDim strValues As String = ipHidden.Value.ToString() Dim strApproved = strValues.Substring(strValues.IndexOf("approved=") + 9, 1)Dim st...

How can I set client side values as server side values?
Hi, Can anyone tell me how I can get client side values such as document.referrer, navigator.appName etc... into server side scripts? There are some client side values I'd like to set as session vars and insert into the db? How do I go about this? Thanks for any pointers Davlon PS (I'm using powersite Pass them as page parameters, e.g., http://myserver/myurl?document.referrer=whatever&navigator.appName=yadayada Then, in your server-side script, just loop through the document.value array and get these values. -- pbm_hopethishelps, Roy Kie...

Change hidden field value on client side, then retrieve on serverside
I am trying to change a hidden field's value on the client side with Javascript, then retrieve it after postback.The hidden field is inside a user control. The user control's containing page attempts to access the hidden field's value in a click event handler, but the hidden field's value still has the old value.However, by the user control's prerender phase the hidden field does contain the new value.I notice that if I use Request.Form, the same behaviour is exhibited.How can I retrieve the hidden field's new value, without having to wait for the prerender stage. Or alternatively, how can I...

Client Side values to Server Side
What is the best way to transfer Client Side values to the Server side? For example I have a variable "var1" in javascript. var1 = "sample"; How can I acquire this value in the server side?  What is the best approach for this?  Barry to send the value to the server during a postback, you need to place the value in an input control.  You could consider using a hidden textbox for that purpose.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/ In the JavaScrip...

Client-side values to server-side ?
Hi! My previous query is attached below: I have implemented the below mentioned implementation . 'listbox1' on 'webform1' shows all the values from 'webform2'. I have implemented it using javascript. I would like to know that to implement validation on 'webform1', I would require the values of 'listbox1' ,which are on the client-side , to move to the server-side . I think sending a querystring will be fine but how to implement it using javascript and code-behind(C#)? Your suggestion will be appreciated. Thanks and regards, ap.       My previous query: " I am stuck wi...

pls help: how to get client-side HTML "text field" value from a server side button
i copy some javascript from somewhere so user can choose pick up a date from a calendar and display the date onto a HTML text field. I have no knowledge in writing client side script(i.e. write code in html) can i write some code in a server-side button to get the value in the HTML text field??? i tried: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click textbox1.text = document.getElementById("htmltext").value End Sub but "document" is highlighted, and say isn't declar yet. and...

Hidden Field that is set on server side...not getting the last updated value from client?
Hi, I have a hidden field that tracks errors in my server side asp.net 2.0 code.  However, when I set the value to an error (from it's default value "NotSet") in the server side code and then when trying to access that Hidden Variable from the client the value is still set to the default value, "NotSet" instead of the error information. Any ideas as to what is going on here? Thanks in advance!   Server Side....  catch (Exception er) { Errors.Value = er.Message; o o o } Client Side.... function getErrors() { var cho = document.getElementById('<%=Errors.ClientID...

Use client side code to get hidden field value from calling page
Hi, I have a web application that is being called from an extranet app. I need to access the value of a hidden form variable on the calling form, I have tried Request.form("Fieldname") & cannot pick up any values. They are not keen on passing the value in the querystring - I would really appreciate some help on this. Thanks If the item is not in the form collection, then they're probably not doing a POST to your page. You can pass information to a page three ways: URL (querystring, fragment, etc), POST (form.submit()), and via a HTTP Header. They'll need to decide...

Web resources about - Hidden field client side value lost on post back - asp.net.client-side

Trump Increases Lead After Call To Block Muslims Entering Country
Donald Trump took a commanding lead in the polls following his call to bar Muslims from entering the country, but his fellow Republicans may ...

'Star Wars: The Force Awakens' brings together 'family' of fans
LOS ANGELES — Don't call them Star Wars fans, call them a Star Wars family. Carrying light sabers, foldable chairs, tents and endless amounts ...

Google speculated to launch Android One 2.0 during Sundar Pichai's India visit
Google rumoured to be working on second version of Android One with more features and 4G facility.

Quentin Tarantino Delivers Shrieking UFC-Style Intros for ‘Hateful Eight’ Cast at Hollywood Premiere
The December 2012 premiere for “Django Unchained” was canceled in the wake of the Newtown, Connecticut, but three years later not even the threat ...

L.A. and Chicago Are Up Next for Google Fiber
Just a day after AT&T announced that it’s bringing gigabit fiber internet to the L.A. metro area , Google has announced that it’s exploring L.A. ...

TOM FRIEDMAN’S UTOPIA: Breathing the Air in Red China is Like Smoking 40 Cigarettes a Day
By Nick Sorrentino The free market is often blamed for pollution. The the unbridled greed of capitalists is the reason rivers flow red, forests ...

Judge Throws out Kansas Man's Murder Conviction
Judge overturns Kansas man's conviction in sister-in-law's 1999 killing

HTC’s Vive VR headset launch delayed until April 2016
HTC announced in a blog post that its Vive VR headset won’t see a commercial launch until April 2016. When the company first showed off the developer ...

Yahoo reportedly gets serious about selling its core business
Yahoo appears to have more than just a casual interest in selling itself off. Both CNBC and the New York Times claim that the web giant has ruled ...

Undercover Greenpeace activists buy off corrupt academics in a climate change sting
The environmental activism group Greenpeace today disclosed that it led an undercover investigation to expose how easy it is for big oil, gas, ...

Resources last updated: 12/9/2015 6:33:51 AM