Questions tagged [asp.net-controls]

ASP.NET Web server controls are objects on ASP.NET Web pages that run when the page is requested and that render markup to a browser. Many Web server controls resemble familiar HTML elements, such as buttons and text boxes. Other controls encompass complex behavior, such as a calendar controls, and controls that manage data connections.

174 questions
40
votes
6 answers

ASP.NET control to render a

The Label control in ASP.NET seems to render tags, but is there a server control to render HTML within a
? Sure, I could set display: block and it might look the same, but I'd rather not be nesting divs inside spans. Also I'd prefer not…
James
  • 7,343
  • 9
  • 46
  • 82
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 …
22
votes
9 answers

How do I disable all controls in ASP.NET page?

I have multiple dropdownlist in a page and would like to disable all if user selects a checkbox which reads disable all. So far I have this code and it is not working. Any suggestions? foreach (Control c in this.Page.Controls) { if (c is…
Mohamed
  • 3,420
  • 7
  • 28
  • 31
20
votes
1 answer

Obtain strongly typed header class in ASP.NET Core

How do you obtain a strongly typed header class from the namespace System.Net.Http.Headers from an ASP.NET Core controller? In a controller derived from Controller, Request.Headers is available, but it just returns IHeaderDictionary. There is also…
Edward Brey
  • 40,302
  • 20
  • 199
  • 253
11
votes
2 answers

PlaceHolder vs Literal for adding HTML markup generated at runtime

This question points out Literal vs Label while this question points out Panel VS. PlaceHolder but just today I was debating with my colleague on using PlacHolder vs Literal for adding HTML markup which is generated at runtime. Both controls do not…
Ahmed Atia
  • 17,848
  • 25
  • 91
  • 133
10
votes
7 answers

Set ClientID in asp.net

Is it possible to set the ClientID of any asp.net server control? How can I do this?
ebattulga
  • 10,774
  • 20
  • 78
  • 116
9
votes
3 answers

Is there a way to put inner controls inside a ASP.NET Custom Control?

I want to do something like (Updated example):
rball
  • 6,925
  • 7
  • 49
  • 77
7
votes
2 answers

ASP.Net ListView Grouping by Data Field?

I uses asp.net listview control to display the details. Each item has the group details. For demo purposes group is hard coded. I want to display the listview as shown below Right now, I have this Code:
One Developer
  • 99
  • 5
  • 43
  • 103
7
votes
5 answers

How can I create a custom Repeater that displays Header, Footer based on properties?

I want to create a Repeater that displays the header/footer based on properties, only if the DataSource is empty. public class Repeater : System.Web.UI.WebControls.Repeater { public bool ShowHeaderOnEmpty { get; set; } public bool…
BrunoLM
  • 97,872
  • 84
  • 296
  • 452
6
votes
2 answers

ASP.NET: explicit vs implicit localization?

To my mind the advantage of implicit localization over explicit localization is that if you have more than one property to localize for a given control, it's a more economical syntax. In the case where you just need to localize some text I use the…
User
  • 62,498
  • 72
  • 186
  • 247
6
votes
5 answers

how to change visible of an asp.net control of master page in content page?

I have a Master Page that have a asp:Panel control and the code that sets Visible = False in it's code behind. Now i want to change Visible = True in one of content page. How do it? Master page code behind: AccountUserInfo.Visible = false; …
Hamid Talebi
  • 1,298
  • 2
  • 24
  • 42
5
votes
2 answers

How to add control to the page programatically in page load?

I am trying to add controls to the page from the code behind in the page load stage like this: foreach (FileInfo fi in dirInfo.GetFiles()) { HyperLink hl = new HyperLink(); hl.ID = "Hyperlink" + i++; hl.Text = fi.Name; hl.NavigateUrl…
Laziale
  • 7,965
  • 46
  • 146
  • 262
5
votes
10 answers

How to reduce this IF-Else ladder in c#

This is the IF -Else ladder which I have created to focus first visible control on my form.According to the requirement any control can be hidden on the form.So i had to find first visible control and focus it. if (ddlTranscriptionMethod.Visible) …
Rohit Raghuvansi
  • 2,824
  • 8
  • 46
  • 74
4
votes
3 answers

Add ASP Controls to a Table Dynamically

Right now I have an ASP Table. I can add rows and cells to this table just fine. What I would like to do, is instead of the cell just displaying text, I would like to add a control. For example a Button. Right now, my first thought on how to do this…
user489041
  • 27,916
  • 55
  • 135
  • 204
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
  • 41,281
  • 29
  • 127
  • 212
1
2 3
11 12