Questions tagged [user-controls]

A UserControl is a separate, reusable input control that allows a user to interact with an application. User controls can be buttons, checkboxes, input text boxes, mice, keyboards, etc.

A UserControl is a separate, reusable input control that allows a user to interact with an application. User controls can be buttons, checkboxes, input text boxes, mice, keyboards, etc.

User controls only exist on graphical systems or applications. For example, a HTTP service application does not contain user controls; its input is usually by means of a configuration file or a separate application providing it input.

10278 questions
29
votes
3 answers

WPF: template or UserControl with 2 (or more!) ContentPresenters to present content in 'slots'

I am developing LOB application, where I will need multiple dialog windows (and displaying everything in one window is not an option/makes no sense). I would like to have a user control for my window that would define some styling, etc., and would…
Tomáš Kafka
  • 4,405
  • 6
  • 39
  • 52
28
votes
5 answers

InvalidCastException for Object of the same type - Custom Control Load

I have a very wired error, one of my custom controls seems that is create two compiled files, and when I try to load it dynamically with LoadControl() is just fail because can not cast the one to the other - even if they are exactly the same. I…
Aristos
  • 66,005
  • 16
  • 114
  • 150
27
votes
2 answers

Can values or parameters be passed into user control?

I haven't used these in awhile. I was just wondering is it possible to pass values or parameters to a user control from the aspx page. Say you register a control and then use it using something like
chobo
  • 31,561
  • 38
  • 123
  • 191
27
votes
2 answers

Custom attribute in UserControl (*.ascx)?

Supposing I have a user control like this I am wondering if I can do something like So that in MyWidget.ascx I can have
Aximili
  • 28,626
  • 56
  • 157
  • 216
27
votes
10 answers

Why is User (as in User.Identity.Name) null in my abstract base controller?

I was asking a related question but messed the title up and no-one would understand it. Since I am able now to ask the question more precisely, I decided to reformulate it in a new question and close the old one. Sorry for that. So what I want to do…
Masterfu
  • 1,191
  • 3
  • 14
  • 26
27
votes
6 answers

How to add an event to a UserControl in C#?

I have a UserControl which contains 3 labels. I want to add an event for it, which occurs when the text of one of the labels changed. I am using Visual Studio 2010
Saeed
  • 7,262
  • 14
  • 43
  • 63
27
votes
3 answers

Wpf UserControl and MVVM

I am thinking about writing a WPF User Control for my application. I am using MVVM in my application. User control's may require Dependency Properties that can be set my Parent View. when using MVVM, the idea is that the Parent View will eventually…
byte
  • 1,665
  • 1
  • 19
  • 36
27
votes
5 answers

Rails: Best practice to store user settings?

I'm wondering what the best way is to store user settings? For a web 2.0 app I want users to be able to select certain settings. At the moment is it only when to receive email notifications. The easiest way would be to just create a Model "Settings"…
Ole Spaarmann
  • 15,845
  • 27
  • 98
  • 160
27
votes
4 answers

When to add a Component Class vs User Control?

I have a general idea, and there are some obvious cases, but there are also some gray areas for me - when is it best to use to extend from a component and when is it best to create a user control? This pertains to a specific work problem I am…
alexD
  • 2,368
  • 2
  • 32
  • 43
26
votes
2 answers

expose and raise event of a child control in a usercontrol in c#

Hi. I have a UserControl which contains a textbox. I wanted to access the textchanged event of the textbox but in the event properties of the usercontrol I don't see the events for the textbox. How can I expose and handle particular events of the…
Anirudh Goel
  • 4,571
  • 19
  • 79
  • 109
26
votes
4 answers

UserControl as DataTemplate inside ListBox

I want to reuse my UserControls in other UserControls like page or window as DataTemplates, in this example inside a ListBox. Everything is MVVM. I've a UserControl called "CardControl" to display a simple object "Card". Card has two Properties,…
pDEV
  • 273
  • 1
  • 3
  • 5
26
votes
2 answers

Raising an event on parent window from a user control in .NET C#

The title pretty much explains the question. I have a user control loaded into the main window when the application is first run. What I want to do is to raise an event on parent window when a button on the user control is clicked, so how can I…
user246392
  • 2,661
  • 11
  • 54
  • 96
26
votes
5 answers

InvalidCastException for two Objects of the same type

I have this weird problem that I cannot handle myself. A class in the model of my mvp-project designed as singleton causes an InvalidCastException. The source of error is found in this code line where the deserialised object is assigned to the…
LLEA
  • 345
  • 1
  • 4
  • 7
26
votes
3 answers

WPF, UserControl or DataTemplate

Recently I'm trying to reuse some UI elements in my application. When I started programming with WPF I'm told that DataTemplate is the best way to reuse UI elements. You can define a template for your data entity and use it everywhere. It sounds…
Zach
  • 5,715
  • 12
  • 47
  • 62
26
votes
10 answers

asp.net user control, getting htmlAnchor resolve to href="#"

How do you get a server control HTMLAnchor to have href="#". It keeps resolving the "#" to the control path. resolves to: I can't seem to get a google search to give me the results i want…
Highstead
  • 2,291
  • 3
  • 26
  • 30