Questions tagged [servercontrols]

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).

213 questions
62
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
  • 11,718
  • 15
  • 59
  • 98
25
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 …
24
votes
16 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
  • 6,823
  • 12
  • 47
  • 81
12
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,129
  • 7
  • 59
  • 120
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
  • 24,434
  • 16
  • 74
  • 162
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
  • 18,415
  • 19
  • 75
  • 116
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... ....
Andy McCluggage
  • 34,336
  • 18
  • 56
  • 67
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
  • 28,156
  • 12
  • 52
  • 92
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,117
  • 16
  • 63
  • 110
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
  • 9,895
  • 6
  • 46
  • 67
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,156
  • 3
  • 17
  • 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
  • 90,244
  • 46
  • 174
  • 217
5
votes
1 answer

Why do ASP.Net server control declarations require the runat="server" attribute?

Surely the fact that they're declared beginning with "
Ray
  • 3,188
  • 8
  • 23
  • 27
4
votes
4 answers

ASP.NET Server Control Property Attribute must be required

I have a custom ASP.NET server control CustomControl with a property attribute Path. If the Path is not explicitly specified, then I want an exception to be thrown. For example,
smartcaveman
  • 38,142
  • 26
  • 119
  • 203
1
2 3
14 15