手动添加文本框控件问题

编程入门 行业动态 更新时间:2024-10-26 06:26:29
本文介绍了手动添加文本框控件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

亲爱的所有人 我在ABC.aspx中添加了一个文本框控件,代码是这样的

Dear All I added a textbox control in my ABC.aspx, the code is like this

<input id="txtSessionKey" name="txtSessionKey" type="text" value=""/>

然后我尝试在ABC,aspx.cs中给它一个值,代码是

Then I tried to give it a value in the ABC,aspx.cs, the code is

txtSessionKey.Value = "123";

但是,当我编译时,出现以下错误:

However, when I compiled, I got this error:

Error 2 The name 'txtSessionKey' does not exist in the current context

我在.NET领域还很新. 如果有人以前解决过这个问题,请帮助我. 谢谢您.

I am quite new in .NET area. please help me if anyone has solved this problem before. Thank you

推荐答案

为了使aspx文件中的任何项目都对后面的代码可见,您必须使用runat ="server"对其进行标记并重新编译.这应该是您需要做的所有事情. In order for any item in your aspx file to be visible to the code behind you have to tag it with runat="server" and recompile. It should be all you need to do.

您好 如果您像下面这样写,则仅在客户端浏览器上可用,这意味着您可以使用客户端脚本(javascript/jQuery)调用此控件,但不能在C#.cs文件中调用 但是,如果要从C#.cs文件访问控件,则必须使用runat属性.如果您运行atat ="SERVER" 谢谢 费萨尔 Hi if you write like below it only availabe on client browser means u can call this control by using client script(javascript/jQuery) but not in C# .cs file but if you want to access the control from C# .cs file u have to use runat attribute . if you runat="SERVER" thanks Faisal

更多推荐

手动添加文本框控件问题

本文发布于:2023-11-11 23:47:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579885.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   文本框

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!