user-controls

What are the purpose of User Controls in Visual C#?

白昼怎懂夜的黑 提交于 2019-12-30 08:22:10
问题 User Controls -- Do they serve a special purpose? As far as I can tell they are no different to forms - they have the same toolbox and features. Are there certain times when they are appropriate to use over forms? It would be interesting to understand what they are good for. 回答1: You use them to group a set of controls and behaviors together in a re-usable way. You can't show a control on the screen unless it's added to a form somewhere. One good example is a textbox. It's very common to have

What are the purpose of User Controls in Visual C#?

て烟熏妆下的殇ゞ 提交于 2019-12-30 08:21:05
问题 User Controls -- Do they serve a special purpose? As far as I can tell they are no different to forms - they have the same toolbox and features. Are there certain times when they are appropriate to use over forms? It would be interesting to understand what they are good for. 回答1: You use them to group a set of controls and behaviors together in a re-usable way. You can't show a control on the screen unless it's added to a form somewhere. One good example is a textbox. It's very common to have

Loading Nested UserControls in ASP.NET

送分小仙女□ 提交于 2019-12-30 07:48:13
问题 I've got an issue with nested controls not loading properly. I've tried various page methods and nothing seems to work. EDIT: The site compiles and runs fine--it just leaves a blank screen though. Basically I have a wrapper control for a Chart that allows me to select data, bind, and customize the chart with a lot of abstraction. I need another wrapper control for that because there may be groups of charts that I want to represent easily. Generalized answers would be great too. Here's what I

How to load a UserControl in WPF with reflection?

夙愿已清 提交于 2019-12-30 07:33:13
问题 private void Window_Loaded(object sender, RoutedEventArgs e) { var assm = Assembly.LoadFrom("wpflib.dll"); foreach (var t in assm.GetTypes()) { var i = t.GetInterface("test.ILib"); if (i != null) { var tmp = Activator.CreateInstance(typeof(UserControl)) as UserControl; this.stackPanel1.Children.Add(tmp); } } } tmp(UserControl1 in wpflib.dll) only contains a label and a textbox. Windows1 (test.exe) reference ILib.dll, and only contains a stackPanel1. But, why there is nothong in Windows1

Enabling design surface on Winforms custom UserControl

我们两清 提交于 2019-12-30 07:30:27
问题 I tried to create a custom user control in C# that handles other controls that are added to it. The custom control consists of two panels. What I'm trying to achieve is, that if another control is dragged to my user control in design mode (or added programmatically at runtime) I want that control to be placed on one of the panels. I tried to handle the OnControlAdded event but that didn't do the trick... 回答1: Markus wrote : "if another control is dragged to my user control in design mode (or

How do you access user controls on a masterpage from the asp:content page using the master?

空扰寡人 提交于 2019-12-30 07:22:06
问题 I keep getting these requests for 'make me a tool to do xyz' for a web app we're putting up. So after the third one, I realized it'd be easier to lump them all together and use a master page. I've got a user control called MessageCenter I use for error, success, and informational messages, and so I dropped that on the master page. <%@ Master Language="VB" CodeFile="tfMasterPage.master.vb" Inherits="tfMasterPage" %> <%@ Register Src="MessageCenter/msgCenter.ascx" TagName="msgCenter" TagPrefix=

AJAX ScriptManager in UserControl

前提是你 提交于 2019-12-30 07:06:07
问题 I have a UserControl that contains an UpdatePanel which wraps some other controls. The UserControl will be used on some pages that already have a ScriptManager and other pages that do not have a ScriptManager. I'd like the UserControl to automatically bring its own ScriptManager if one does not exist. I have tried ScriptManager.GetCurrent and if it returns null i create my own ScriptManager and insert it into the Form but I can't find a place early enough in the UserControl's lifecycle to run

How to make usercontrol available to multiple projects?

自古美人都是妖i 提交于 2019-12-30 05:21:04
问题 I have a set of UserControls in a ASP.NET website that I would like to share to multiple website. But it seems we are unable to create a class library with UserControls in it with the ascx file. While MSDN suggest building a Web Control, I Would rather find a way to share the existent controls instead of destroying them to create new web controls. Is there any way of creating a library of UserControls? Thanks 回答1: Here is one way of doing it: Creating and Using User Control Libraries. 回答2:

How to put a custom windows forms control in a WPF application?

血红的双手。 提交于 2019-12-30 03:26:09
问题 As a short term solution I'm trying to jam a windows form 'usercontrol' into a WPF application. I see in the WPF application view that I can add a 'custom windows form control' to the project and it makes an empty custom control, but I can't figure out how to add it. Ideally I'd like to know how to take the .dll from my compiled windows forms user control and stick it into the WPF app, or import the user control into the WPF application. Thanks, Sam 回答1: You can't really add it as a control

Programmatically rendering a web UserControl

試著忘記壹切 提交于 2019-12-30 02:33:06
问题 I have a load of UserControl objects ( ascx files) in their own little project. I then reference this project in two projects: The REST API (which is a class library project) and the main website. I'm sure this would be easy in the website, simply use Controls.Add in any Panel or ASP.NET control would work. However, what about the API? Is there any way I can render the HTML of this control, simply by knowing the type of the control? The RenderControl method doesn't write any HTML to the