txt_userid在当前上下文中不存在 [英] txt_userid does not exist in the current context

查看:141
本文介绍了txt_userid在当前上下文中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 cmd = new SqlCommand(从登录中选择User_ID,其中User_ID ='+ txt_userid.Text +',con); 






这个文本框中的
id是txt_userid有设计页面但是当前上下文中不存在probelm txt_userid



请帮助我,



i想要正确的解决方案。

解决方案

如果你是不使用代码隐藏的文本框,

它不允许你从其他类访问它导致它的默认修饰符是私有的。

所以如果你使用的是文本框而不是形式代码隐藏尝试...



将文本框修饰符从私人更改为公开


< blockquote>您是否直接从ASP.Net codebehind或任何其他类使用此文本框。实际上这个场景对我来说并不清楚。请用您的代码进行描述。


cmd = new SqlCommand("select User_ID from login where User_ID='" + txt_userid.Text + "'", con);




in this textbox id is txt_userid have on design page but probelm is txt_userid does not exist in the current context

please help me,

i want correct solution.

解决方案

If you are not using the textbox from codebehind,
it will not allow you to access it form other classes cause its default modifier is private.
so if you are using textbox not form codebehind try...

Change TextBox Modifier from Private to Public


did you use this textbox direct from ASP.Net codebehind or any other class. Actually the scenario is not clear to me. Please describe it with your code.


这篇关于txt_userid在当前上下文中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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