Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linq asp.net mvc 13 25
TimeZone, day light savings, Sql server, asp.net 6 40
VS 2015 is giving [No relevant source lines] 2 40
Asp.Net Session Question 2 36
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
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.

730 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