w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Tap event on dynamically added custom control is handled by another control of same type
I figured out the problem, and I am chocking it up to lack of experience with WPF. When I made my Waypoints I created them like to var newWaypoint = new Waypoint(waypointNumber, latitude, longitude); newWaypoint.Name = "wayPoint" + waypointNumber; newWaypoint.Opacity = 100; double leftMargin = CalculateLeftMargin(longitude); double topMargin = CalculateTopMargin(latitude); newWaypoint.Margin = new Thickness(leftMargin, topMargin, 0, 0); LayoutRoot.Children.Add(newWaypoint); The problem with that was that I was setting the Margin of the control. When I set the Margin it was actually stretching out my Waypoint so I was having Waypoints on top of Waypoints. After some research I came across this article Changing Position of an Element Programmatically in WPF which showed me how to prope

Categories : C#

Button sizes changing on user control when control is added to window
You have don't have your LastChildFill property set to False on your top DockPanel. This is the reason "Ent" is changing size and moving your screen. You also have the HorizontalAlignment on "Del" set to stretch. Try setting that to Left, but might be moot with the LastChildFill correction. The overall resizing is do to HorizontalAlignment set to Stretch set that to Left.

Categories : Wpf

Reference a user control by name in code behind (dynamically created)
Just store the references to the controls somewhere instead of their names, e.g. in a List<CheckBox>, then you can access them by index. Also you actually should not do any of that, use data-templating and data-binding to create controls for data. If done right you just need to change a boolean on your data and the check-box will be checked/unchecked.

Categories : C#

how to add picture box control and label control dynamically in list view control
Did you google around? There are lot of links that can help you http://geekswithblogs.net/dotNETvinz/archive/2009/04/24/faq-displaying-image-from-database-to-gridview-control.aspx http://weblogs.asp.net/aghausman/archive/2009/05/26/show-images-on-grid-view-from-file-stream.aspx http://www.codeproject.com/Articles/20782/Displaying-Images-from-a-Database-in-a-GridView http://www.codeproject.com/Articles/20971/Thumbnail-Images-in-GridView-using-C

Categories : Asp Net

adding Control to form but gap keeps doubling when added at Bottom of previous control
this is more of a hack but it works. sharpUserX.Size = sharpUserSize PnlSharpUsers.Controls.Add(sharpUserX) sharpUserX.Location = pnlAddBtn.Location if i set the size before i add the control, then set the location after it seems to apply the font scaling to the size, but not the location, which works perfectly for me.

Categories : C#

How to find dynamic control inside a dynamically added container
Try this.Works for me try replacing the contentplaceholder with the form id may work. String Value= (this.Form.FindControl("ContentPlaceHolder1").FindControl("panel").FindControl("txtbx" ) as TextBox).Text;

Categories : C#

Retrieving ascx control value from a callback registered on master page. Control added to Repeater's PlaceHolder during OnItemCreated
I'm not sure what changed, maybe it was taking the break to rubber duck debug using all of the above. I've gone back and tried tweaking some of the things I had before (order of insertion, which call to use, etc) to see if they make a difference, but either way, the Control is now being persisted in the ViewState properly with the above code. It is available on postback from the master page call so long as the following is added (bullet #1 of what I tried before): protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); RefreshOptions(); } Earlier, savedState was only showing the List<int> added to it to maintain selected options. At some point in tweaking and debugging, I saw that the controls I created were now in the

Categories : C#

DotNetNuke User control not working .it shows data from .resource file in Portal>0>cache>pages.Not able to debug User control
I have a series of DNN tutorials that I started on recently (I wrote a majority of the old ones on dotnetnuke.com) that talk through the process of setting up your development environment, and then using the Visual Studio Templates that I have created/released (open source). I would encourage anyone trying to really do any development with DotNetNuke to check those out. http://www.christoc.com/tutorials

Categories : C#

How to put control id based on parent control reference/ID to avoid conflict
I think you can differentiate by using the id edit-issue-dialog if($("#edit-issue-dialog").length){ //u r in edit form, and do your stuff }else{ //in create form do your stuff }

Categories : HTML

dynamically created wpf control doesn't work the same as the control it is based on
You aren't setting IsHiteTestVisible = false on your Rectangle. That is the problem, because your ContentPresenter is on top of the MoveThumb in your template. I'm not sure what the MoveThumb looks like, but if it is just a transparent rectangle, I'd put that on top of the ContentPresenter so you don't have to worry about setting IsHitTestVisible on all the children you add.

Categories : Wpf

get reference of a user control in dependent project
Well I would declare interface, lets say interface IControl { void foo(); } in Project2, have this tab1.ascx implement this interface, and type control once you find it to this interface. (This interface can be also defined in Project3 that will be referenced by both Project1 and Project2).

Categories : Asp Net

Open User Control from user control in main window grid WPF
This is just a guess as you've not provided much information, but I noticed the following issue which may be the culprit. In your first code snippet, you seem to be creating the employee from the MainForm: Dim Empl As New Employee MainGrid.Children.Add(Empl) Grid.SetRow(Empl, 1) Your following comment would seem to confirm that assumption: This is from Window_Loaded event. Menu is User Control, and there I have few buttons to open and operate another user controls. When I press for example button "Question" And yet, in your Employee class, you are creating a brand new instance of MainWindow and then adding data to it: Public Class Employee Dim mw As New MainWindow Private Sub btnQuestionAdd_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnQu

Categories : Wpf

Getting the error "The name does not exist in the current context" when trying to reference a user control
You need to use the x:Name attribute, not just Name. <uc:StandardDialog x:Name="StandardDialog" ... Windows Store applications don't automatically create a field for objects with their Name specified. The x:Name attribute is required if you want a named field to be created and available to the code behind.

Categories : C#

WPF user control bind data to user control property
You can try Element binding inside the user control. Just give a name to UserControl and bind property: <UserControl x:Class="controlmaker.checkButton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="114" d:DesignWidth="221" x:Name="MyUserControl"> <Grid Background="Aqua" > <CheckBox Content="CheckBox" Height="16" HorizontalAlignment="Left" Margin="58,24,0,0" Name="checkBox1" VerticalAlignment="Top" /> <Button Content="{Binding Path=buttText, ElementName=MyUserC

Categories : Wpf

Losing styles when adding a User Control to a User Control
In general it is good practice to keep your styles separate from the markup. This makes maintenance easier and it also saves yourself from searching for the reason one of your elements appears a pixel away from where you are expecting (for example... Similar issues can be exasperating). Do you have the same issue if you set the CssClass attribute for your button(s) and set the styles in a css file for the class?

Categories : C#

How to access the main page control values in user control
To retrieve, for example, a textbox defined in the aspx page from an ascx control contained in it you could try: Dim myTextBox As TextBox = Ctype(Me.Parent.FindControl("myTextBoxName"), TextBox) Note that the control you want to retrieve must have a runat="server" attribute otherwise it can not be seen server side. In your question you posted three controls without runat="server"; you could use instead: <asp:HiddenField ID="HiddenField1" runat="server" Value="1" /> <asp:HiddenField ID="HiddenField2" runat="server" Value="2" /> <asp:HiddenField ID="HiddenField3" runat="server" Value="3" /> In this case the above command would become: Dim myHiddenField As HiddenField = Ctype(Me.Parent.FindControl("myHiddenFieldName"), HiddenField)

Categories : Asp Net

Access Parent Page Control in Child User Control
You will have something like this in tab control. <cc1:TabContainer ID="TabContainer1" runat="server"> <cc1:TabPanel ID="TabPanel1" runat="server"> <ContentTemplate> <asp:DropDownList id="dropdownlist1" runat="Server"/> </ContentTemplate> </cc1:TabPanel> So first you need to find tabPanel1 then find dropdownlist1 like following. TabContainer TabContainer1= (TabContainer)(this.Page.FindControl("TabContainer1"); if (TabContainer1!=null){ TabPanel TabPanel1= (TabPanel)(this.TabContainer1.FindControl("TabPanel1"); if(TabPanel1 !=null){ DropDownList dropdownlist1= (DropDownList)(this.TabPanel1.FindControl("dropdownlist1"); }}

Categories : C#

How can I bind a parent control's TextBox from inside a user control
You can declare the DataContext property of the <TextBlockControl /> as the Text property of the "editor" <TextBox />: <wpfSandbox:TextBlockControl DataContext="{Binding Text, ElementName=editor}" /> and inside your control: <Grid> <TextBlock Text="{Binding}" /> </Grid>

Categories : Wpf

How to make binding from user control to property of parent control?
ElementName binding works within in same XAML scope. This will work - <Grid> <CheckBox Name="checkBox1"/> <Label Content="{Binding ElementName=checkBox1, Path=Name}"/> </Grid> But if you want to do it in different UserControl, you have to tweak a bit your code and use Tag to hold name - <Grid> <CheckBox Name="checkBox1"> <local:UserControl1 Tag="{Binding ElementName=checkBox1, Path=Name}"/> </CheckBox> </Grid> UserControl.xaml <Canvas> <Label Content="{Binding Path=Tag, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"/> </Canvas> On a sidenote, in your UserControl, you know you need to bind with ElementName = checkBox1 and that's

Categories : Wpf

FlowLayout Control With User Control Item Template Not Binding
Try: public UserControl2() { InitializeComponent(); Loaded += (sender, args) => { var obj = (ViewMod)this.DataContext; if (obj == null || obj.Prop == null) return; var d = obj.Prop; if (d == null) return; grd2.Children.Add(new TextBlock { Text = d.Name }); }; } DataContext is not set instantly. Hence we use the Loaded event and add a lambda to it to do your corresponding steps. side-note: even-though this works, please do search and look at some MVVM examples. While having no code-behind is not really an MVVM requirement, I think your taking it a bit too far adding Grid children and stuff from code-behind when you can do it perfectly fine from xaml.

Categories : C#

Dynamically load User Controls into a Web Control without Register Tags
Well you can load them dynamic on page load like this: private const string UCFolderName = "~/Controls/"; ... var usercontrolA= Page.LoadControl(UCFolderName + "UsercontrolA.ascx"); ServercontrolContainer.Controls.Add(UsercontrolA); where ServercontrolContainer is a element in your .ascx file

Categories : C#

Accessing controls located in a dynamically created user control vb.net
As @HansPassant said you just need to add properties to your user control to get access to your controls in it. I'm not a vb.net guy, but I think this is going to help you: Public Function MyTextbox() As System.Windows.Forms.TextBox Return Textbox1 End Function You can write this in your user control code.

Categories : Vb.Net

Css and js files references in user control created dynamically in placeholder
I think its a path problem, try removing the ~ from the path's in the user control. Edit: try replacing the ~ with .. Edit: I see that your targeting the image via ID, but this is a runat="server" control. so it will be rendered with a different ID (you can see that in your HTML). to target the image via ID (in JQuery), you will have to resolve the Client Id (you can find a lot of topics about how to do that), but you will not be able to do that in CSS. so instead: you can give the image a class, and target the image via class selector (in JQuery and CSS). this is the easiest way. Final Solution (from the owner responce) I added the references in the web form and remove it to the user control and works good. Thank for your support, but indeed, the ID was a issue.

Categories : Jquery

How to pass data from user control to main control in wpf
You can set the DataContext(viewmodel) of the user control same as that of Main Window. Keep a property in viewModel and Bind that Property in the user control. So whenever anything changes in the Control that property will automatically be updated in the View Model which can be used by the Main

Categories : Wpf

Can we control speed of value updating in a WPF user control
Create a buffer between the control and the fast changing data source. You could create a buffer by making a class with a property that will keep track of when the last update to its property was made and only when it is more than 500 ms ago will update the property. private int _stockRate; private long _lastUpdate = 0; public int StockRate { get { return _stockRate; } set { long now = getTimeInMilliseconds(); // Stopwatch or other timer if(now - _lastUpdate > 500ms) { _stockRate = value; _lastUpdate = now; OnPropertyChanged("StockRate"); } } }

Categories : Wpf

VB.NET WebBrowser Control Programmatically Filling Form After Changing User-Agent (Object reference not set to an instance of an object.)
Do you realize .All("btnK") returns a collection? So, you are doing .InvokeMember("click") on a Collection :). You cannot do that, you can only do .InvokeMember("click") on an element for obvious reasons! Try this: wb.Document.All("btnK").Item(0).InvokeMember("click") The .Item(0) returns the first element in the collection returned by .All("btnK"), and since there will only probably be one item returned, since there is only one on the page, you want to do the InvokeMember on the first item, being .Item(0). May I ask what it is you are developing? Since you're a new user, please up-vote and/or accept if this answered your question.

Categories : Vb.Net

How to add an html control inside a div or crate a new control beside another control
var myA=document.createElement("a"); would create an element, you can set it's text by myA.innerHTML and src with myA.src="http://www.google.com" To add it to the page you can do: document.getElmentById("mydiv").appendChild(myA); to remove: var As=document.getElmentById("mydiv").getElementsByTagName("a"); var a = As[As.length-1]; a.parentElement.removeChild(a);

Categories : Javascript

Bind a reference to a non-reference object to a Form's Control in C#
I cannot say I understand your question completely, but if you wish to make your non-reference type "variables" (fields?) reference-able, you can put them inside of a class. For example, create a dictionary field mapping strings or integer constants to a FieldBase class, then store in that dictionary all the FieldBase objects you need, and look them up by name. The FieldBase class can be non-generic, and derived classes generic: abstract class FieldBase { public readonly string Name; protected FieldBase(string name) { Name = name; } } sealed class Field<T> : FieldBase where T : struct { public Field(string name) : base(name) { } public T Value; }

Categories : C#

Added control to form has no name
Add "Name" attribute Msdn doc : http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.name.aspx

Categories : C#

Attibutes added twice in custom textbox control
This is happening because you're calling base.AddAttributesToRender(writer); at the end if the if statement. Instead of calling base here just add a line to add the id attribute: writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ID);

Categories : C#

Missing functionality of added Control in another application
Whilst it is technically possible to do what you want, it is excruciatingly difficult. Raymond Chen wrote about this at some length. The executive summary: Is it technically legal to have a parent/child or owner/owned relationship between windows from different processes? Yes, it is technically legal. It is also technically legal to juggle chainsaws. So, you are attempting something with difficulty akin to juggling chainsaws. Unless you have a deep understanding of Win32 you've got no chance of succeeding. So, if you want to modify the GUI of an existing process, and it's not tractable to do so with code in a different process, what can you do? Well, it follows that you need to execute code inside the target process. That's easy enough to do with DLL injection. Inject a DLL into

Categories : Delphi

How to reference a Control in VBA
It's correct as long as Courses is CodeName of your sheet but I don't think so. As long as Courses is simple name which you could see in Excel App then you need to change your code into this one: Sub ListBox7_Change() With Sheets("Courses").ListBox7 .AddItem "Hi" End With End Sub

Categories : Excel

Getting data back from composite control added to placeholder on postback
I asked this a long time ago, But I think this is how you should do it. Using a factory pattern for user controls. http://weblogs.asp.net/sfeldman/archive/2007/12/17/factory-pattern-for-user-controls.aspx

Categories : Asp Net

JQuery Mobile loses style when runat="server" is added to the control
Thanks for the guys in the comments section I found the reason. When rendered the checkbox id is changed from chckTOC to cpmain_chckTOC and the label tag it was not valid. I've changed the label tag to <label for='cpmain_chckTOC' /> and now I've got a brand new styled checkbox as expected. I've also managed to avoid this hardcode id -> <label for='cpmain_chckTOC' />, because it would be a problem for example, if you have your checkbox inside an APS repeater - then each checkbox id will be different something like "cpmain_repeaterid_chckTOC_1" and then "cpmain_repeaterid_chckTOC_2" and so on. And in this situation hardcoded id won't help you. Instead I've managed to do it using only ASP.NET controls: <asp:CheckBox runat="server" ID="chckSelectAll" CssClass="custom" />

Categories : Asp Net

c# reference on programatically created control
Hold a reference in a class-level variable when you create the DataGridView control, and then use that variable to add the rows: //Class-level variables private DataGridView _gridView; public void create_Tab_Control() { //Logic to create the Tabs _gridView = new DataGridView(); //Add the DataGridView to the TabControl } public void add_row() { //Add the row(s) to the DataGridView _gridView.Rows.Add("column 1", "column 2"); }

Categories : C#

Add Partial Control dynamically in ASP .NET MVC
Thanks to @satpal He put his answer and after that deleted it. I don't know why. But he is right! Html.RenderAction((string)@ViewBag.InitializeUserControl); This is working!

Categories : C#

How can I use wildcards or regular expressions to control Path-based authorization / access control for svn?
as of June 2013 it is impossible to do this. So, the solution to the problem is to re-organize the repository so this isn't necessary. When a thing is too difficult it usually leads to a large rethink of the design or approach. At present maven structure leads to this requirement: root/pom.xml root/project1/pom.xml root/project2/pom.xml etc.. We can replace this with /root/pom.xml /project1/pom.xml /project2/pom.xml etc.. We can set the svn perms as follows granting all read access to the top level project and read write to their project. If an continuous integration build server populates an internal maven repo with the root snapshot then the users only need to checkout specific projects. [repo:/root] * = r @releng = rw [repo:/project1] @teamOne = rw [repo:/project2] @teamTwo =

Categories : Svn

How to link or reference a UI control such as a button in code
I'm not sure if I understood your question, but assuming you have a Button with a specified name on a Window. The only way you can access that button in another class is by having access to that window instance in that class. I believe the window can be casted as a frameworkelement and you can use the method FindName Here to find an element inside that window. However this only works is you have access to the instantiated Window inside that class.

Categories : C#

How to Reference a Vectored Graphic in Control Binding
The fact, that the in Template is used to Path and it assumes a string value in the Data parameter. But now you use DrawingBrush, usually it is used for Rectangle control. So, we change the type of attached depending properties on the type of DrawingBrush: public static readonly DependencyProperty IsCheckedOnDataProperty; public static void SetIsCheckedOnData(DependencyObject DepObject, DrawingBrush value) { DepObject.SetValue(IsCheckedOnDataProperty, value); } public static DrawingBrush GetIsCheckedOnData(DependencyObject DepObject) { return (DrawingBrush)DepObject.GetValue(IsCheckedOnDataProperty); } static CustomCheckBoxClass() { PropertyMetadata MyPropertyMetadata = new PropertyMetadata(null); IsCheckedOnDataProperty = DependencyProperty.RegisterAttached("IsCheck

Categories : C#

How to get a reference to a label in a Repeater control in code-behind
I would recommend reorganize your code a little bit, which will allow you to perform such operations easily using FindControl. Basically my suggestion boils down to handling Command event not of the link button, but of the repeater itself: <asp:repeater id="rpt" run="server" OnItemCommand="rpt_ItemCommand"> Then access to item contents is extremely easy: protected void rpt_ItemCommand(object sender, RepeaterCommandEventArgs e) { Label label = e.Item.FindControl("lblMessage"); LinkButton linkButton = e.Item.FindControl("Delete"); }

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.