user-controls

Access child user control's property in parent user control

ぐ巨炮叔叔 提交于 2020-01-11 06:37:14
问题 I have included a user control in another statically following code : place the folowing directive in the asp code of the parent page or usercontrol: <%@ Register src="Name_of_your_child_control.ascx" tagname="Name_of_your_child_control" tagprefix="uc1" %> use the following tag in the asp-code of the parent page/control: <uc1:Name_of_your_child_control ID="Name_of_your_child_control1" runat="server" /> ..... But the issue is...i am not able to access the public properties of user control

JavaScript Function Definition in ASP User Control [duplicate]

时间秒杀一切 提交于 2020-01-11 05:41:06
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: User control javascript I defined a JavaScript function inside a user control. If I have multiple instances of the user control on my .aspx page, how do I prevent multiple function definitions in the resulting HTML code? 回答1: You'll want to use the Page.ClientScript manager. The following code will only register your code once per a page. if (!page.ClientScript.IsClientScriptBlockRegistered(tType, "MyScript")) {

Making an indexed control array?

你说的曾经没有我的故事 提交于 2020-01-11 03:06:10
问题 Has C# indexed control arrays or not? I would like to put a "button array" for example with 5 buttons which use just one event handler which handles the index of all this 5 controls (like VB6 does). Else I have to write for each of these 5 buttons one extra event handler. And if I have 100 buttons, I need 100 event handlers? I mean something like that: TextBox1[i].Text="Example"; It could make coding definitely easier for me to work with control arrays. Now I have seen, that C# at least has

How to set CommandTarget for MenuItem inside a ContextMenu?

心已入冬 提交于 2020-01-10 08:03:10
问题 (This question is related to another one, but different enough that I think it warrants placement here.) Here's a (heavily snipped) Window : <Window x:Class="Gmd.TimeTracker2.TimeTrackerMainForm" xmlns:local="clr-namespace:Gmd.TimeTracker2" xmlns:localcommands="clr-namespace:Gmd.TimeTracker2.Commands" x:Name="This" DataContext="{Binding ElementName=This}"> <Window.CommandBindings> <CommandBinding Command="localcommands:TaskCommands.ViewTaskProperties" Executed="HandleViewTaskProperties"

How to set CommandTarget for MenuItem inside a ContextMenu?

守給你的承諾、 提交于 2020-01-10 08:03:07
问题 (This question is related to another one, but different enough that I think it warrants placement here.) Here's a (heavily snipped) Window : <Window x:Class="Gmd.TimeTracker2.TimeTrackerMainForm" xmlns:local="clr-namespace:Gmd.TimeTracker2" xmlns:localcommands="clr-namespace:Gmd.TimeTracker2.Commands" x:Name="This" DataContext="{Binding ElementName=This}"> <Window.CommandBindings> <CommandBinding Command="localcommands:TaskCommands.ViewTaskProperties" Executed="HandleViewTaskProperties"

Using a ComboBox, UserControl and some forms to change language (for entire project)

一个人想着一个人 提交于 2020-01-10 05:50:33
问题 Before I begin, I have researched and can't seem to find anything. Note I am very new to UserControl so this might be why it's proven difficult. I have a combobox in Form1 which when selected allows the user to change between a choice of 21 languages. I have created a UserControl that contains labels, buttons and checkboxes - adds to a form called Print. If a user selected French, how would I then implement the UserControl to change language for ALL forms in my project? UserControl: I have

how to move the cursor between textboxes using arrows?

和自甴很熟 提交于 2020-01-10 05:45:15
问题 I have several textboxes , i want the cursor to move from one textbox to another using arrow keys. how can i do that? it looks like this, also the tap moves vertically which is weird. Thanks. 回答1: You can override the form's ProcessCmdKey function, and handle the key press and focusing on text boxes in it. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;

Binding UserControl View model on MainWindow with MVVM

女生的网名这么多〃 提交于 2020-01-10 04:27:05
问题 I am newbie to WPF and MVVM and I am trying to learn how WPF working with MVVM. For that, I have made a sample as follows UserControl1.xaml <StackPanel> <TextBox Text="{Binding MyString}" /> </StackPanel> UserControl1ViewModel.cs class UserControl1ViewModel { public string MyString { get; set; } } MainWindow.xaml <StackPanel> <local:UserControl1 DataContext="{Binding UC1Property}"/> //tried binding the Usercontrol1VM obj on MainWindowVM <Button Command="{Binding ShowMeOne}" Height="30"

Binding UserControl View model on MainWindow with MVVM

扶醉桌前 提交于 2020-01-10 04:27:01
问题 I am newbie to WPF and MVVM and I am trying to learn how WPF working with MVVM. For that, I have made a sample as follows UserControl1.xaml <StackPanel> <TextBox Text="{Binding MyString}" /> </StackPanel> UserControl1ViewModel.cs class UserControl1ViewModel { public string MyString { get; set; } } MainWindow.xaml <StackPanel> <local:UserControl1 DataContext="{Binding UC1Property}"/> //tried binding the Usercontrol1VM obj on MainWindowVM <Button Command="{Binding ShowMeOne}" Height="30"

How can I detect whether a user control is running in the IDE, in debug mode, or in the released EXE?

房东的猫 提交于 2020-01-10 03:52:07
问题 I have a user control that I'm building. It's purpose is to display the status of a class to the user. Obviously, this does not matter, and will slow things down when the control runs in the IDE, as it does as soon as you add it to a form. One way to work around this would be to have the control created and added to the controls collection of the form at run-time. But this seems less than perfect. Is there a way to set a flag in the control so that it can skip certain sections of code based