会话状态提供错误和QUOT;在上下文中QUOT不存在; [英] Session state giving errors "does not exist in context"

查看:152
本文介绍了会话状态提供错误和QUOT;在上下文中QUOT不存在;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧......我尝试设置一些会话状态变量,但即时取回错误:

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

错误3'txtFirstName'这个名字并不在目前的情况下存在

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"] = txtStartDate.Text;
Session["txtEndDate"] = txtEndDate.Text;

而我打字这code,文本字段名称,如txtLastName是在智能感知雨后春笋般冒出来,这样会导致我相信他们在上下文中,但IM仍然收到此错误。我也试过:

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.

推荐答案

听起来像它可能是隐藏文件的code的一个问题。

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

有时(我不是,为什么会发生这种情况100%,但我已经看到它在过去)的* .aspx.designer.cs可以停止更新自身。

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.

解决这个问题的解决方法是删除* .aspx.designer.cs文件,并通过右键点击* .aspx文件创建它并选择转换为Web应用程序。

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.

这篇关于会话状态提供错误和QUOT;在上下文中QUOT不存在;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆