Solved

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

Posted on 2007-11-29
6
1,306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
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 set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

628 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