user-controls

How to use TwoWay binding from within a UserControl?

扶醉桌前 提交于 2020-01-03 09:44:09
问题 I have my own UserControl, a LabeledTextBox which is the combination of a Label and a..well, TextBox . This Control has two properties: Caption which will be bound to the caption of the Label , and Value which will be bound to the Text of the TextBox . Code: public class LabeledTextBox : Control { static LabeledTextBox() { DefaultStyleKeyProperty.OverrideMetadata(typeof(LabeledTextBox), new FrameworkPropertyMetadata(typeof(LabeledTextBox))); } public string Caption { get { return (string

WPF, cannot bind a property because it says it's not a DependencyProperty, but I registered it

坚强是说给别人听的谎言 提交于 2020-01-03 03:37:08
问题 I have a UserControl with a Template property that I've set up as a DependencyProperty : public partial class TemplateDetail : UserControl { public static readonly DependencyProperty _templateProperty = DependencyProperty.Register( "Template", typeof(Template), typeof(TemplateDetail) ); public TemplateDetail() { InitializeComponent(); Template = new Template(); DataContext = Template; } public Template Template { get { return (Template)GetValue(_templateProperty); } set { SetValue(

Injecting javascript from a user control inside an UpdatePanel

烈酒焚心 提交于 2020-01-03 03:31:09
问题 When the page initially renders, the initializeControl function is called and everything works. When the page performs a full post-back (via a submit button), the initializeControl function is also called and everything works. When there is partial post-back of the UpdatePanel , though, the initializeControl function is never called and the control stops working. HTML: <asp:ScriptManager ID="myScriptManager" runat="server" /> <asp:UpdatePanel ID="myUpdatePanel" runat="server">

Add row datagridview at every button click

為{幸葍}努か 提交于 2020-01-03 03:09:06
问题 I have on a usercontrol a datagridview. I created a datatable and I set the source of datagrid to be this datatable. I want,at runtime,to be able to add how many rows on gridview I want at every button click. My code : private DataTable CreateTable() { Datatable table=new Datatable(); table.Columns.Add("Name".ToString()); table.Columns.Add("Size".ToString()); DataRow dr = table.NewRow(); dr["Name"] = "Mike"; DataRow dr2 = table.NewRow(); dr2["Name"] = "Ryan; DataRow dr3 = table.NewRow(); dr3[

How to communicate between ASP.net custom controls

◇◆丶佛笑我妖孽 提交于 2020-01-03 03:06:15
问题 I'm using two custom controls. One gathers the criteria for a search, and the other displays a list. These two controls need to remain seperate for the time being. What is the best method of transfering data from the search control, to the list control? I'm thinking of ViewState, Session or wrapping both within a UpdatePanel and using custom events?? 回答1: Maybe you can create a delegate and an event to pass a list of searchvalues? This way you can easily add another or multiple display

Casting a TabItem to UserControl in WPF

微笑、不失礼 提交于 2020-01-02 14:03:43
问题 I have a Tab Control on my main screen. It has different tab items. For example: <TabControl Name="mainTab" Padding="0" Margin="70,80,350,49"> <!--Left,Top,Right, Bottom--> <TabItem GotFocus="TabItem_Animals_GotFocus"> <TabItem.Header> Animals </TabItem.Header> <ContentControl Margin="10"> <Frame Name="animalFrame" Source="AnimalWorkSpaceView.xaml"></Frame> </ContentControl> </TabItem> <TabItem GotFocus="TabItem_Calfs_GotFocus"> <TabItem.Header> Calfs </TabItem.Header> <ContentControl Margin=

How do I get design mode to work for templated user controls?

孤街醉人 提交于 2020-01-02 05:58:17
问题 Is it possible to get design mode to work for templated user controls? I have tried following the How to: Create Templated ASP.NET User Controls on MSDN, and also tried the various tips at the bottom of page for version 2.0 of the framework, but alas, I still get the dreaded "Error creating user control" error, when switching to design view. Should I just give up, and switch to a custom server control? 回答1: There is a Connect bug filed on this as well as several comments on the VS2005 version

How do I get design mode to work for templated user controls?

狂风中的少年 提交于 2020-01-02 05:58:07
问题 Is it possible to get design mode to work for templated user controls? I have tried following the How to: Create Templated ASP.NET User Controls on MSDN, and also tried the various tips at the bottom of page for version 2.0 of the framework, but alas, I still get the dreaded "Error creating user control" error, when switching to design view. Should I just give up, and switch to a custom server control? 回答1: There is a Connect bug filed on this as well as several comments on the VS2005 version

ASP.NET: Register multiple controls at once via namespace?

北城余情 提交于 2020-01-02 05:06:08
问题 Is it possible to register a complete namespace of usercontrols in an aspx-File, instead of each control seperately? I have created a bunch of usercontrols and collected them into an own namespace "MyWebControls", like this: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LevelFilter.ascx.cs" Inherits="MyWebControls.LevelFilter" %> Codebehind: namespace MyWebControls { public partial class LevelFilter : System.Web.UI.UserControl { ... } } What I tried now to include them in my

WPF How to get a UserControl to inherit a Button?

北城余情 提交于 2020-01-02 01:01:28
问题 I created a UserControl which consists of a couple ellipses and labels. I added it just fine to another form and things were looking pretty snazzy. Then I went to start adding some event handlers and discovered that the control I made did not expose a Click event. Oops. Easy to fix, right? Just go back to the code-behind on the UserControl I made and let it inherit Button. Unfortunately, doing this caused a "Partial declarations of MyControl must not specify different base classes" message.