如何在ASP.NET服务器控件中访问HTML控件的id [英] How to access id of HTML control in ASP.NET server control
问题描述
我想在asp.net服务器控件中访问HTML控件的id。如何访问它。
代码:
HTML控制
- ----------------------
I want to access id of HTML control in asp.net server control. How to access it.
code:
HTML control
-----------------------
<input type="text" id="question-title"/>
----------------------
ASP.NET控件
-----------------------
----------------------
ASP.NET CONTROL
-----------------------
<asp:TextBox ID="txtQuestionTitle" runat="server" placeholder="title" />
---- ----------------
所以上面的代码代表html和asp.net控件。我想在asp.net服务器控件中访问question-title。 html代码中的id指的是css中的样式。
----------------
css
----------------
--------------------
SO the above code represents html and asp.net control. I want to access "question-title" in asp.net server control. the id in html code refers to the style in css.
----------------
css
----------------
#question-title,#question-details,.taglist .input input {
float: left;
width: 82%;
}
------------------------------
我尝试了什么:
我尝试将id更改为类,但没有效果可见。
------------------------------
What I have tried:
I have tried changing the id into class but no effect is visible.
推荐答案
您不能在服务器控件的ID中使用连字符。你需要使用CssClass =question-title来更新css
You can't have a hyphen in a server control's ID. You'll need to use CssClass="question-title" instead and update the css
.question-title,#question-title,#question-details,.taglist .input input {
float: left;
width: 82%;
}
这篇关于如何在ASP.NET服务器控件中访问HTML控件的id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!