开发者

Session state giving errors "does not exist in context"

开发者 https://www.devze.com 2023-02-17 19:44 出处:网络
Ok... im trying to set some session state variables but im getting back the error: Error3The name \'txtFirstName\' does not exist in the current context

Ok... im trying to set some session state variables but im getting back the error:

Error 3 The name 'txtFirstName' does not exist in the current context

Here is what I added into the event handler of a submit button

Session["txtFirstName"] =
txtFirstName.Text;
Session["txtLastName"] = txtLastName.Text;
Session["txtPayRate"] = txtPayRate.Text;
Session["txtStartDate"] = txtSt开发者_如何转开发artDate.Text;
Session["txtEndDate"] = txtEndDate.Text;

while i was typing this code, the text field names such as txtLastName were popping up in intellisense, so that would lead me to believe that they ARE in context, but im still getting this error. I've also tried:

HttpContext.Current.Session["txtFirstName"] = txtLastName.Text;

But that was giving the same error. Im stumped. Am i forgetting something? Do I need to add something else in. My book is very vague on the subject and the lab instruction don't give anything helpful.


Sounds like it may be a problem with the code behind files.

Sometimes (I'm not 100% on why this can happen but I've see it in the past) the *.aspx.designer.cs can stop updating its self.

The solution to this is to delete the *.aspx.designer.cs file and recreate it by right clicking on the *.aspx file and choosing "Convert to web application".

This should regenerate the designer file and fix the issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消