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
2
votes
4 answers
Problems in the global namespace when I try to use my custom server control (in the App_Code directory)
Traditionally I use the regular asp.net website (created using the File > New Website). Recently, I opted to work off of a full fledged project (created using File > New Project > ASP.net Web Application).
I've been using the same custom controls…

Steve French
- 961
- 3
- 13
- 38
2
votes
0 answers
How does ASP.Net ensure the correct binding order of internally-bound controls?
If I have something like this:
' Visible='<%# DataTime.Now.Days == 1 %>' runat="server">
How does .Net determine the order of binding? In that example, it needs to bind…

Deane
- 8,269
- 12
- 58
- 108
2
votes
1 answer
CssClass and default images in ServerContol
I'm writing a ServerControl in ASP.NET 3.5, and I'm exposing CssClass, so the user can manipulate the visual appearance of the control. My problem is that I want to establish reasonable defaults, so that the user doesn't have to configure CSS…

Jeff Dege
- 11,190
- 22
- 96
- 165
2
votes
3 answers
How to embed a static image resource in a web server control?
I am going to create a web server control representing a treeview. So I want to use 2 images for + and - for expand/collapse. How can I build this into the control in a way that can be used as image source when rendered on the page?
Since this will…

awe
- 21,938
- 6
- 78
- 91
2
votes
0 answers
Subclassing a Custom Control when doing it right is not possible?
I have a stand alone custom control that is extensively deployed.
It has one public property (ClientIdentifier) and two methods (OnLoad and RenderContents)
Over the years there have been some if clauses added to handle certain client specific…

Chris Cudmore
- 29,793
- 12
- 57
- 94
2
votes
2 answers
Validating textbox in Server Control using RequiredFieldValidator
I have custom server control, which contains three textboxes. I need to validate its content using ASP.NET field validators.
I set 'ControlToValidate' property of RequiredFieldValidator to the ID property of my textbox, but it seems that the…

Eadel
- 3,797
- 6
- 38
- 43
2
votes
0 answers
asp.net server control not saving state properly
I am trying to create an ASP.net server control that uses controls from the AjaxControlToolkit. Essentially, the control is a dropdownlist and a button. When the user clicks the button, a modal dialog (modalPopupExtender) opens. The dialog has a…

jason
- 3,821
- 10
- 63
- 120
2
votes
1 answer
Reordering controls on asp.net page
Is it possible to reorder HtmlGenericControls that are statically put on a page? For example I have a menu that has a container element for each section. I want to reorder the position of the sections.
…

chobo
- 31,561
- 38
- 123
- 191
2
votes
2 answers
How to use Server Controls with PostBack with ASP.NET MVC?
Once I click the button, it throws a "Validation of viewstate MAC failed" exception. I know MVC does not support PostBack but is there any way to work around this?
Or we need to use HtmlHelper in MVC?
Below is my code in View:

Gabriel Chung
- 1,527
- 1
- 18
- 30
2
votes
3 answers
Server controls in an asp.net repeater
Seems like I've ran into a wall here. I want some datasource to be bound to an asp.net repeater (well, doesn't have to be a repeater, but it seems like that's what I want). Now, here's the catch: I also need some server-controls inside that repeater…

cwap
- 11,087
- 8
- 47
- 61
2
votes
7 answers
The correct pattern for passing data to child controls in a server control
I'm working with a 3rd party system to implement some forms in a website.
The 3rd party system provides me with XML definitions for these forms.
e.g.

Greg B
- 14,597
- 18
- 87
- 141
1
vote
1 answer
ASP.NET C# Checkbox Realtime Validation
Trying to get two checkbox controls to work with each other. Pseudo-code example:
If Checkbox 1 is checked,
Look at checkbox 2 and make sure it is not checked.
If checkbox 2 is checked, then uncheck Checkbox 2.
and Vice Versa.
I kind of have it,…

Android Student
- 153
- 2
- 12
1
vote
2 answers
use a javascript from embeded resource of a custom control on a page
I have a custom server control which renders some HTML on the aspx page it is added.
protected override void RenderContents(HtmlTextWriter output)
{
Text = GetHTMLContent();
output.Write(Text);
}
the GetHTMLContent()…

dipdawiz
- 13
- 3
1
vote
1 answer
My custom server control is generated as System.Web.UI.UserControl in the designer file
I created a server control which consist only of fews buttons.
CWNavigation.vb
{0}:CWNavigation>")> _
_
Public Class CWNavigation
Inherits WebControl
I then referenced…

Rushino
- 9,415
- 16
- 53
- 93
1
vote
1 answer
ASP.NET Treeview control default behavior
I have a page using a Treeview server control like so:
What I expect to have happen is my treeview should render a series of checkboxes,…

Tim
- 4,051
- 10
- 36
- 60