Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to access id of HTML control in asp.net server control. How to access it.

code:

HTML control
-----------------------
HTML
<input type="text" id="question-title"/>
----------------------
ASP.NET CONTROL
-----------------------
ASP.NET
<asp:TextBox ID="txtQuestionTitle" runat="server"  placeholder="title" />


--------------------
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
----------------
CSS
#question-title,#question-details,.taglist .input input {
	float: left;
	width: 82%;
}


------------------------------

What I have tried:

I have tried changing the id into class but no effect is visible.
Posted
Updated 15-Mar-16 1:25am
v2
Comments
[no name] 15-Mar-16 0:50am    
As per your code "question-title" is a css class which used in server side control and id of HTML control. So what are you trying to accomplish?

1 solution

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%;
}
 
Share this answer
 
Comments
A94 16-Mar-16 8:16am    
I have tried it already but no effect is visible
F-ES Sitecore 16-Mar-16 8:34am    
I just tried it and it works fine, you probably haven't amended the text control or the css, or both.

<style>
.question-title,#question-title,#question-details,.taglist .input input {
float: left;
width: 82%;
}
</style>
<asp:TextBox ID="txtQuestionTitle" runat="server" CssClass="question-title" placeholder="title" />

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900