Solved

Easy points for hidden fields and setting value in code behind file

Posted on 2007-11-29
6
1,295 Views
Last Modified: 2013-12-23
Can you set hidden form field values in the code behind file when enable view state is set to false???
Here is my code:

Dim hidDenCanc As HiddenField = FormView11.FindControl("hidCancDeny")

        hidDenCanc.Value = "Yes"

but when the round trip is made from the server, the hidden form field is back to its original value when checking for t on the page load event.
0
Comment
Question by:wolfcoop
  • 2
  • 2
6 Comments
 
LVL 9

Expert Comment

by:divinewind80
ID: 20375319
Just to be sure, are you setting this code in the following:

If Not IsPostBack() Then
Dim hidDenCanc As HiddenField = FormView11.FindControl("hidCancDeny")
End If

Otherwise, you will be reseting every time...
0
 

Author Comment

by:wolfcoop
ID: 20375355
No its set in selectedindexchanged sub routine of a drop down, so it does not get set unless the value of the drop down is changed.  The problem is the drop down gets changed, and the value gets set

Dim hidDenCanc As HiddenField = FormView11.FindControl("hidCancDeny")

        hidDenCanc.Value = "Yes",

then the page travels to the server showing a couple of new drop downs, but on the Page load event the hidden form field has the original value, not the value set by the sub routine.  View state is not enabled, so does it just load in a fresh page, with the original form field values???  Hence the hidden variable gets set and then to the server and gets dropped because its not passed back???????
 
0
 
LVL 9

Expert Comment

by:divinewind80
ID: 20375449
It sounds as if the PageLoad event, or the control's OnLoad event is indeed setting the value back to its default.  I assume this control is not created dynamically, correct?

If this is the case, you should be able to use the Not IsPostBack.  This will make it only rebind the data if the page is loaded for the first time... not on every postback.

Can you show more code?
0
 

Author Comment

by:wolfcoop
ID: 20375540
its ok I figured it out.  I am a moron.  I just gave up on setting the hidden field value, and read the drop down list selected value in the onload.  if it = Select then its not the cancel deny process, but any ther value and I take them back to the cancel/deny view of the multiview.  Thanks for trying, but a solution is better than knowledge at this point.  And to answer your question no its a hard coded hidden field on the particular multiview view.

Page load did not reference the control other than checking the value of the hidden field, and the control has no onload event defined.  No worries though, its working now, was just banging my head up against it.

Thanks
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 20561738
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now