usercontrols

User control in .Net during development

Hello I've noticed that when developing an user control in vs2008, that I have to build the user control each time I want to see the changes that I've made. Changes that usually doesnt requiere that I build the project aren't visible until I compile and build the project. This mean that it take a lot more time to develop since the site ...

What's the last possible event I can catch after a user control has been shown in .net, winforms?

Hi, as the title says, I'm looking for an event to catch after a user control has been shown. At the moment, I have to set a do-once variable and catch the Invalidated event. ...

C# UserControl constructor with parameters

Call me crazy, but I'm the type of guy that likes constructors with parameters (if needed), as opposed to a constructor with no parameters followed by setting properties. My thought process: if the properties are required to actually construct the object, they should go in the constructor. I get two advantages: I know that when an ob...

ASP.NET Controls lose their ID when postback?

I have a usercontrol that contains 2 textboxes. When the page is postback, the ID of those 2 textboxes disappear? The value stay there when the Ajax is called (ontextchanged). I noticed that the method "LoadPostData" of IPostBackDataHandler is not called after a postback (but only when the Ajax is called). Any ideas? ...

ASP.NET - Control Events Not Firing Inside Repeater

This is a absurdly common issue and having exhausted all of the obvious solutions, I'm hoping SO can offer me some input... I have a UserControl inside a page which contains a repeater housing several controls that cause postback. Trouble is, all of the controls inside of the repeater never hit their event handlers when they postback, bu...

Exposing DataGrid SelectedItem in parent UserControl in WPF

Hi there, I have a User Control with a Data Grid inside it which i re-use in a couple of different Pages and am using M-V-VM. How can I / is it possible to expose the Data Grid's SelectedItem dependancy property as a dependancy property on the User Control which contains it??? The goal being that in a Page using the control, i could ...

How to instantiate a descendant UserControl?

Here is the scenario. I have a bunch of UserControls that all inherit from MyBaseControl. I would like to instantiate a UserControl based on its name. For instance: void foo(string NameOfControl) { MyBaseControl ctl = null; ctl = CreateObject(NameOfControl); // I am making stuff up here, ...

How do I animate UserControl objects using Storyboard and DoubleAnimation?

In my WPF application, I have a Canvas object that contains some UserControl objects. I wish to animate the UserControl objects within the Canvas using DoubleAnimation so that they go from the right of the Canvas to the left of the Canvas. This is how I have done it so far (by passing the UserControl objects into the function): pri...

Silverlight 3: Using list of UserControls as ItemsSource for TreeView

I want to populate a TreeView with UserControls, but I only want the Name property to show up, not the entire UserControl. The following code gives me weird crashes as soon as I add something to myUCs: C#: var myUCs = new ObservableCollection<UserControl>(); MyTreeView.ItemsSource = myUCs; XAML: <controls:TreeView x:Name="MyTreeView...

User control question (Not working right)

I have a user control (a country selector, select a country and it populates a 2nd DropDownList with the states/regions for that country without reloading the page). The control works fine if there's nothing in the QueryString, but as soon as I add something to the QueryString, such as http://www.example.com/test.aspx?ACC=3 then the cont...

User Control not getting declarative property value.

I have a user control on a web form that is declared as follows: <nnm:DeptDateFilter ID="deptDateFilter" runat="server" AllowAllDepartments="True" /> In the code-behind for this control, AllowAllDepartments is declared as follows: internal bool AllowAllDepartments { get; set; } Yet when I view the page, and set a breakpoint in the ...

WPF design UserControl / DataTemplate problem

Hi! I have a question. I have a WPF UserControl representing a Person with many fields. Some Persons can be a company. In this case I'd like to use another template with other fields. The code behind is the same, that's why I want it as a 1 control only with 2 templates. What I'd like to do is to be able to define these 2 templates wi...

Why don’t Asp.Net controls expose the same events as…?

Hi User control receives same events as Page object and just like Page object also exposes Application, Session, Request and Response objects. I realize UserControl class and Page class both inherit from same TemplateControl class and for that reason share so many of same methods and events. But then why don’t Asp.Net controls such as...

Are master pages the way to go?

I may be nuts, but master pages scare me because I fear that once I am locked into using a master page, I will encounter a situation where I will want to inherit only 90% of the visual content of the master page, forcing me to break the inheritance and thus having to reproduce the content that was in the master and bring it into the chil...

Accessing user controls’s constituent controls from a hosting web page

Hi I’ve read that user control’s constituent controls can be accessed only by user control and thus web page that hosts this user control cannot receive the events, call methods or set properties of these contained controls. But I’m not sure the above claim is true, since I was able to access ( from hosting web page ) ClickButton.C...

Silverlight UserControl Binding

Hi I have a simple User Control Xaml: <UserControl x:Class="GraemeGorman_Controls.Navigation.NavigationItem" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <Border x:Name="borderLayoutRoot"> <TextBlock x:Name="textBlockCaption" Text="{Bi...

Relative script path in usercontrol

Hi, I have asp.net usercontrol that is including some js script like this <script type="text/javascript" language="javascript" src="../JScripts/JScripts.js"/> The problem is that when I am using this usercontrol in some pages, it works correctly, but when using some pages in another folder structure, it fails with the file not found e...

C#: Drag drop controls on surface

Is there a way that one can make a control, such as a textbox, drag-droppable in C#? I want the user to have the ability to click and hold the control with the mouse and drag it around on its surface and drop it anywhere within that surface. Anyone has any idea how to implement this? ...

WPF - It is possible to get all UI controls with their values

It is possible in WPF to get all UI controls with their values? In example i have some window with some textboxes and in another window I want to get entered values from the first window textboxes or other input elements. In WinForms it was something like: form.Controls; ...

WPF, UserControl or DataTemplate

Hi, 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 very good. However, I also found some disadvantages, especially when it is compared wit...