用户控件中控件的静态ID [英] Static Id of controls in usercontrol

查看:100
本文介绍了用户控件中控件的静态ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在通过Request.Form("control Id")
在文件后面的Asp.net代码中使用控件ID 我创建了一个带有文本框的用户控件,并定义了属性
ClientIDMode="Static"使得control-id是可预测的,但是在控件中,.NET让我大名鼎鼎.
一个小片段是:

 <   div      ="  > 
    <   asp:Label     ID   ="   runat   服务器"  CssClass   标签" 文本   QuestionText" / > 
    <   asp:TextBox     ID   ="   TextMode    MultiLine "  runat   服务器"  ClientIDMode   静态" / > 
<  /div  >  




当我说Request.Form["TbxQuestion"]时,我得到NULL.
我正在使用VS2010和Asp.Net 4.0(C#是语言).

专家请帮忙.
我是.NET的新手,因此会为错误找借口.

解决方案



U可以在模型后面的代码中的任何位置通过"TbxQuestion.Text"访问文本字段的值

Keshav,


您的r绝对正确.......请检查以下链接

http://aspdotnetcodebook.blogspot.com/2008/03/how-to- create-textbox-control.html [ ^ ]


Hello All,

I am using controls id in Asp.net code behind file through Request.Form("control Id")
I have created a user control which is having text box and I have defined property
ClientIDMode="Static" so that control-ids are predicable but I am getting big names by .NET in control.

A small snippet is :

<div class="DivLblText">
    <asp:Label ID="lblQuestionText" runat="server" CssClass="label" Text="QuestionText" />
    <asp:TextBox ID="TbxQuestion" TextMode="MultiLine" runat="server" ClientIDMode="Static" />
</div>




When I say Request.Form["TbxQuestion"] I am getting NULL.
I am using VS2010 and Asp.Net 4.0 (C# is language).

Experts please help.
I am new to .NET hence excuse for mistakes.

解决方案

Hi,

U can access the value of text field by "TbxQuestion.Text" anywhere in code behind model


Hi Keshav,


Your r absolutely right................Check the below link

http://aspdotnetcodebook.blogspot.com/2008/03/how-to-create-textbox-control.html[^]


这篇关于用户控件中控件的静态ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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