Solved

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

Posted on 2007-11-29
6
1,293 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

757 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

18 Experts available now in Live!

Get 1:1 Help Now