A server control in classic ASP.NET is a component that dynamically renders a segment of markup to the client. Controls can be written in markup or coded, and can be bound to data and participate in different phases of the ASP.NET request-handling lifecycle. Out-of-box examples range from the simple (CheckBox which wraps the HTML input checkbox) and more complex (GridView which can be bound to various data sources and has built-in paging and sorting).
Questions tagged [servercontrols]
213 questions
65
votes
5 answers
ASP.NET Control to HTML tag equivalent
I'm looking for a cheat sheet that will allow me to show an HTML designer the equivalent asp.net controls for standard HTML tags. As an example the will render as an HTML
and an will render as an HTML . I've…

stephenbayer
- 12,373
- 15
- 63
- 98
26
votes
4 answers
How to register custom server control on ASP.NET page
I have a project and I am trying to register a custom server control (there is no .ascx file) on the page. I am currently using
Class Declaration
namespace MyApp.Controls{
public class CustomControl: WebControl{
public string Text
…

smartcaveman
- 41,281
- 29
- 127
- 212
24
votes
17 answers
Change Text Box Color using Required Field Validator. No Extender Controls Please
I need to change color of TextBox whenever its required field validator is fired on Clicking the Submit button
Badmate
23
votes
4 answers
Prevent wrapping tags for ASP.NET server control
I am writing various ASP.NET Server controls and am needing to remove the tags that wrap my control by default. I am aware that you can change the tag to a different tag (as in this question, How Do I Change the render behavior of my custom control…

Program.X
- 7,250
- 12
- 49
- 83
13
votes
3 answers
How to set specific ID for server controls in an ASP.NET Web Form that is using a MasterPage?
Is it possible to set a specific ID on an ASP.NET server control? Everytime I assign an ID and run the web form the ID changes.
For Example:
Gets translated into this:

Edward
- 7,346
- 8
- 62
- 123
11
votes
4 answers
Ambiguous Reference in namespace
I have a server control as a class within my MySite assembly (i.e., my site's project not only contains aspx files but also contains server controls which those aspx files reference). I use the following code within an aspx file:
<%@ Register…

Brian
- 25,523
- 18
- 82
- 173
9
votes
2 answers
How to create ASP.NET user/server control that uses a list of asp:ListItem as child controls?
I am looking to create a user/server control that will be created with something like the following:

slolife
- 19,520
- 20
- 78
- 121
9
votes
3 answers
Is there any way to declaratively pass code-behind property values to server controls?
Can anyone explain why you can’t use inline code blocks within server control declarations in ASP.Net?
The following is a simple example...
....
7
votes
3 answers
Convert User Controls to Server Controls
I'm wondering if anyone has any experience converting User controls to Web controls?
Ideally, I'd like to offload some of the design work to others, who would give me nicely laid out User Controls. Then, I could go through the process of…

Chris Cudmore
- 29,793
- 12
- 57
- 94
7
votes
6 answers
retrieve ID of server control using jQuery
How do I get the ID of a server control with jQuery?
E.g. I have
and now I want to get "label1",
var id = ??

AGuyCalledGerald
- 7,882
- 17
- 73
- 120
7
votes
5 answers
How do I make my ASP.NET server control take an embedded code block as a property value?
I have a custom server control with a property of Title. When using the control, I'd like to set the value of the title in the aspx page like so:
more…

Jeff Martin
- 10,812
- 7
- 48
- 74
7
votes
3 answers
Creating an asp:Button programmatically?
I'm using my code-behind page to create a save button programmatically:
Button btnSave = new Button();
btnSave.ID = "btnSave";
btnSave.Text = "Save";
However I think this must create an html button or perhaps needs something else as I…

Jay Wilde
- 2,714
- 3
- 20
- 19
5
votes
3 answers
Using HtmlTextWriter to Render Server Controls?
I'm writing the RenderContents() method of my ASP.NET server control. The method uses an HtmlTextWriter object to render the output content. For the control I'm writing, using the HtmlTextWriter's methods seems like it will require a lot of lines of…

Dan Herbert
- 99,428
- 48
- 189
- 219
5
votes
3 answers
Content within a user control
I am almost too embarrassed to ask this question, but here we go...
I am not an expert with user controls, and need some design advise regarding trying to achieve a specific desired functionality.
The goal is to have a usercontrol that would…

nokturnal
- 2,809
- 4
- 29
- 39