w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Create a custom server control with nested optional controls
tl;dr I ended up using the MultiView control. It doesn't allow duplicate IDs but it satisfies all my other requirements and it allows me avoid having to maintain any custom code. What I tried I was finally able to get something working with this code: using System.Collections.Generic; using System.Linq; using System.Web.UI; namespace CustomControls { [ParseChildren(true)] [PersistChildren(false)] public class VersionedContent : Control { public string VersionToUse { get; set; } [PersistenceMode(PersistenceMode.InnerProperty)] [TemplateContainer(typeof(ContentContainer))] [TemplateInstance(TemplateInstance.Multiple)] public List<Content> ContentVersions { get; set; } public override ControlCollection Controls

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#

Binding controls dynamically to PlaceHolder in asp:DataList
You are not adding the control to the page. You need to add it: Control ctrl = (Control)Page.LoadControl("MyControl.ascx"); // MyControl ctrl = new MyControl(); ctrl.SomeProp = "xyz"; ph.Controls.Add(ctrl);

Categories : C#

The RadListView control does not have an item placeholder specified
The error you are getting does means that you should declare a control in your LayoutTemplate which to determine where the items (ItemTemplate, EditItemTemplate etc.) should be instantiated. Please refer to this live demo for a sample of how to construct RadListView programmatically.

Categories : C#

Fail to continously add new control into Panel/Placeholder during partial postback
Unless a dynamically added control is added at the preinit or init stage, it does not persist beyond a post back. So when the button is clicked for the second time, the first added control is lost and then the button logic adds a control again, leaving you with one control every time. For a control added after the init stage, you would need to store its state and recreate it on each postback. This is described int this article: http://www.codeproject.com/Articles/3684/Retaining-State-for-Dynamically-Created-Controls-i You may also be able to achieve your goals without using dynamically added controls. One possible approach is to use a ListView control, add a FileUpload control to its ItemTemplate and add a new record to the list view data source every time the button is clicked.

Categories : C#

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

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

Is using HTML controls in asp.net effective than using asp.net control.?
If you definitely do not want to add ViewState overhead, then use HTML controls rather than ASP.NET server controls. But beware, ViewState is the glue for a lot of ASP.NET server controls being able to "remember" their values between post backs to the server. If you want more control over the output HTML, then use HTML controls, because the HTML control will map directly to the corresponding HTML element, rather than be rendered as potentially another HTML element or group of HTML elements, for example: ASP.NET Literal server control will not render as an element, but rather just text. ASP.NET GridView server control will render as an HTML table container, by default, and then literal text for BoundFields and various other elements for TemplateFields. ASP.NET CheckBoxList server control

Categories : C#

foreach control c# skipping controls
Surprised that's not erroring on you, since you're modifying the collection as you're iterating over it. Use a for loop and start at the end: for (int ii = Controls.Count - 1; ii >= 0; ii--) { Control cntrl = Controls[ii]; Controls.remove(cntrl); cntrl.Dispose(); } (Starting at the end because otherwise you'd be changing the indexes of each control as you iterated.)

Categories : C#

Placing controls under User Control
I'm pretty sure that that won't work. When you set the content of MyControl to the button you're saying that the whole content of the user control should be the Button. I think you need to have a property on your user control then bind the contentpresenter to that. So Something like MyUserControl.SubContent {get; set;} then you can bind the ContentPresenter to that.

Categories : C#

one COMBOCHART that control by Controls and dashboards
This appears to be a duplicate of the issue posted in the Google Visualization API forums (here), but for the StackOverflow crowd, here is my response: I see a few potential issues here: you are populating a <select> element with options and then immediately firing the "change" event handler, which expects there to be a selected <option>, but you don't set a default selected option, so this will return null (or undefined, or error out, depending on how picky the browser is). you are creating a new div with the id "ComboChart" and appending it to a div with the id "ComboChart". If "ComboChart" already exists, you are breaking the HTML rules that require elements to have unique IDs (which could cause this problem); if "ComboChart" doesn't already exist, then you are failing t

Categories : Javascript

How to hide control when other two controls are already hidden?
you can use Multibinding and a MultiConverter on Label1.Visibility to do this job or you use Style Trigger for your Label1 and set the initial visibility to hidden and use 2 triggers to set the visibility to visible if one of the controls are visible EDIT <Label x:Name=Label1> <Label.Style> <Style TargetType="Label"> <Setter Property="Visibility" Value="Hidden"/> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=ctl1, Path=Visibility}" Value="Visible"> <Setter Property="Visibility" Value="Visible"/> </DataTrigger> <DataTrigger Binding="{Binding ElementName=ctl2, Path=Visibility}" Value="Vi

Categories : Wpf

How can I get my web controls to display over an activex control?
Short Answer, and the solution i used, was to stop using activex, or just use a plain select box, which will render over the control. Any of the nice CSS/Jquery select boxes (select2, chosen) will not display over activex...

Categories : HTML

Dynamically showing a control next to other controls, in different containers
The Location of ProductName TextBox is relative to the GroupBox, but your code treats it as being relative to the Form. You need to offset the coordinates by adding the GroupBox coordinates to them. pt.Offset(groupBox.Location); this.dGVinvisible.Location = pt;

Categories : Dotnet

WebBrowser control get all controls on a thread not working
BeginInvoke() is asynchronous. That delegate yuns on the UI thread after the rest of your code finishes. You want Invoke(), which will synchronously wait for the delegate to finish running.

Categories : C#

how to access controls inside asp repeater control
Not sure what controls do you want to access, but 1) make them runat="server" and give them ID 2) add event handler to repeater for ItemCreated, or ItemDataBound events 3) access control like this: void R1_ItemCreated(Object Sender, RepeaterItemEventArgs e) { var label = (Label)e.Item.FindControl("YourItemId") }

Categories : Asp Net

How to control WPF Controls using Kinect hand pointer?
You can't mouseclick programically, but You can trigger the onclick event handler manually, like: Button_Click(object sender, EventArgs e) {} // - the function that handles the onclick You trigger it manually like this: YourKinectFunction() { Button_Click(this, new EventArgs()); } It will work just as if you clicked the button with mouse. The Button_Click(object sender, EventArgs e) is the function which is executed when the event happens. If you trigger the event in your code, the handler will fire. The function doesn't 'know' who triggered the event (unless you specify it in sender parameter).

Categories : C#

Control Firefox in C#.net like Microsoft Internet Controls
This example search string inside search bar of firefox .if firefox not opened it will open with search option. if it already opened then it will bring it to front and search string again.. you can modify to achieve what you want . Use UI SPY tool to see windows ui automation practically using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; using System.Windows.Automation; using Utils; namespace ControllerX.Executions { /// <summary> /// this class provide searching mechanisms /// </summary> class searching { public static void search(string Sentence) { if ( String.IsNullOrEmpty(Sentence)==true ) return

Categories : C#

Bootstrap control-group, controls class
if you cannot use a form tag try using <div class="form-horizontal"></div> this will give you the alignment you are looking for form-horizontal form-inline and form will give you options to change the layout flow of your page. Edit: Why? Lets say for example you would like to change how the form is displayed at different resolutions. Having the form class apply style to the child control-group you can use the same mark up and have it display different results by only changing the class attribute on the form. IMO it seems a much easier way then rewriting all of the dom elements surround your inputs/ labels.

Categories : Twitter

How to make all new Controls inherit new, Extended Control
You would have to manually re-create each control you want inheriting from Ctrl. e.g. public class TextBoxCtrl : Ctrl { /* implementation */ } EDIT: to avoid having to re-invent the wheel, I'd probably tackle it the following way: First, make the added properties part of an interface so it's more a control you can hand-off: public interface ICtrl { Boolean HasBorder { get; set; } Boolean ShouldDrawBorder { get; set; } } next, work out a helper method (in a separate class) that will handle the UI enhancements: public static class CtrlHelper { public static void HandleUI(Control control, PaintEventArgs e) { // gain access to new properties ICtrl ctrl = control as ICtrl; if (ctrl != null) { // perform the checks necessary

Categories : C#

User Control embedded on a page changes ClientID of controls
This happens because your control is a subclass of UserControl class, which implements INamingContainer interface. By default all controls that implement this interface prepend children's IDs with their own IDs, thus insuring that every ID on the page is unique. To aviod this behavior you have two options: Create server control, inheriting not from UserControl but from Control class directly. This one does not implement INamingContainer. However you won't have markup file, and have to generate all controls programmatically. [Edit: ASP.NET 4 only] Use ClientIDMode="Static" for child controls. This mode insures that server and client IDs of the control are exactly the same. In this case this is a job of a developer to make sure that this control is used only once on the page to avoid ID d

Categories : C#

Windows Phone - Display control in front of other controls
I believe you can fix it with grouping; which ever one you have in the code first will be displayed first. If you have two images grouped together, then it is going to try and display both of them at the sametime.

Categories : C#

Access controls not properties in XAML User Control
Check out these links C# usercontrol how to access all child controls how to get child user control by id from a parent panel user control? http://www.daniweb.com/software-development/csharp/threads/141469/how-to-access-child-control-of-a-user-control

Categories : C#

Accessing MainWindow's controls from a user control page. WPF C#
You could find the WpfPageTransitions.PageTransition control like this from the UserControls code behind: public static WpfPageTransitions.PageTransition FindPageControl(DependencyObject child) { DependencyObject parent= VisualTreeHelper.GetParent(child); if (parent == null) return null; WpfPageTransitions.PageTransition page = parent as WpfPageTransitions.PageTransition; if (page != null) { return page; } else { return FindPageControl(parent); } } Then you can use it like this: this.FindPageControl(this).ShowPage(...);

Categories : C#

How do I copy a control between forms and still maintain child controls?
in the form you want to copy the control to try this: Dim tc As New TabControl tc = New Form1().TabControl Me.Controls.Add(tc) The tabcontrol should be copied to the other form with all the properties intact.

Categories : Vb.Net

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#

How to use the Controls and Forms of Visual Studio to access the TFS Version Control
It is possible, the following I used for TFS2010 and found it somehwere in the internet, it opens the SourceControlFileSelector: VersionControlServer versionControlServer = (VersionControlServer)tfsConnection.GetService(typeof(VersionControlServer)); Assembly controlsAssembly = Assembly.GetAssembly(typeof(Microsoft.TeamFoundation.VersionControl.Controls.ControlAddItemsExclude)); Type vcChooseItemDialogType = controlsAssembly.GetType("Microsoft.TeamFoundation.VersionControl.Controls.DialogChooseItem"); ConstructorInfo ci = vcChooseItemDialogType.GetConstructor( BindingFlags.Instance | BindingFlags.NonPublic, null, new Type

Categories : Dotnet

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

Is there any premade function to help resize controls based on their parent control?
You've not gone into a huge amount of detail in your question, but you can Anchor controls in WinForms which will cause them to automatically resize as the size of the parent changes. Alternatively you could also use Dock.Fill which will tell your control to fill it's parent container and will resize in a similar way to anchoring.

Categories : C#

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>) error
If for a moment forget the reason that cause the error, the results are that the page complain that can not render it because is found the <%= %> that is a direct render of string to the page. One solution is to use a Literal control and render there on code behind what we like. For example: function delayedAlert() { document.getElementById('<asp:Literal runat="server" id="txtTheId" EnableViewState="false" />').style.display = 'inherit'; timeoutID = window.setTimeout(labelhide, 3000); } and on code behind txtTheId.Text = Label3.ClientID.ToString(); Of course this is only the idea to bypass the error, you can render the full javascript on code behind, you register the script or you can just render the id as variable. For example: <asp:Literal runat="serv

Categories : C#

PostBackTrigger for control inside Placeholder inside wizard FinishNavigationTemplate
This seems to work, but if someone has a better solution I'll gladly accept it PostBackTrigger trigger = new PostBackTrigger(); trigger.ControlID = "offerWizard$FinishNavigationTemplateContainerID$lbtnClick"; updPanel.Triggers.Add(trigger);

Categories : Asp Net

Error : Object null reference when trying to get a control from Form.Controls collection
As I said in my comment you can't use a control's name as the indexer of Controls collection to get it but you can iterate through the controls collection find the desired control and do whatever you want with it, try this: Label lbl = null; foreach (var control in this.ParentForm.Controls) { if (((Control)control).Name == "lblMenuItem") { lbl = (Label)control; break; } } if (lbl != null) lbl.Text = "Medical College List"; or if you want to write less code : Control[] foundControls = this.Controls.Find("lblMenuItem", true); if (foundControls.Any()) foundControls.First().Text = "Medical College List";

Categories : C#

Syntax issue in finding the textbox controls used in a GridViews emptytemplate control
Here's how you will get the ID's: Public Sub writeProductInfo(ByVal sender As System.Object, ByVal e As System.EventArgs) 'BindGridView() Dim productID As String = DirectCast(gvProductNumber.Controls(0).Controls(0).FindControl("txtAltprodID"), TextBox).Text Dim productNumber As String = DirectCast(gvProductNumber.Controls(0).Controls(0).FindControl("txtAltprodNum"), TextBox).Text Dim oDs As New DataSet() oDs.ReadXml(Server.MapPath("~/xml/PersonDataVI.xml")) oDs.Tables.Add("product") oDs.Tables("product").Columns.Add("productID") oDs.Tables("product").Columns.Add("productNumber") Dim oDr As DataRow = oDs.Tables("product").NewRow oDr("productID") = productID oDr("productNumber") = productNumber

Categories : Asp Net

How to disable all the controls on windows phone by displaying a semi transparent control over the page?
Use Blend to specify VisualStates (View | States. Then 'states' tab.) You can switch between states in code behind using VisualStateManager.GoToState. One state would be normal, the other all controls disabled. Mike

Categories : C#

'StaticResource MyTemplate' is not a valid value for the 'System.Windows.Controls.Control.Template' property on a Setter
You are trying to set the value of the Template property to the actual literal string "{StaticResource MyTemplate}". You need to look up the resource instance using something like this: var myTemplate = Application.Current.TryFindResource("MyTemplate") as ControlTemplate; // Do something appropriate if myTemplate is null Setter st = new Setter(Control.TemplateProperty, myTemplate);

Categories : Wpf

The Controls collection cannot be modified because the control contains code blocks(i.e.<% ...%>) ajax toolkit html editor
I have faced this error before. Solution is, check in your master page, if you have javascript with <% ... %> block, then remove it from head and add in body section. Hope it helps you.

Categories : Javascript

Get HTML control in formview control on server
If you added html controlls with runat="server" you can access it with Request.Form[ControlName.UniqueID] otherwise, you need to add name="yourcontrol" and you will get the controls in Request.Form["YourControlName"].

Categories : Asp Net

placeholder vs. data-placeholder, in HTML
They can't possibly produce the same results. placeholder is part of the HTML5 spec to show placeholder text in the field before anything is typed, while data-* is just generic data attached to the element. You might have some JavaScript polyfill or something on the page that uses data-placeholder.

Categories : HTML

Asp.net server controls in webmatrix
Google Javascript Calendar Widget or something like that. Many exists but are not "controls" per se. If you want an API I think both Google and Yahoo Calendar have easy copy past calendar widget's. You will need an account to run either under.

Categories : C#

Adding custom server controls into MVC
You cannot use your ascx or dll custom controls in MVC. Mostly, because the lifetime of ASP.net controls is different. In MVC - controls just render HTML, They don't receive any postback, they don't save controlstate or viewstate. Even "Page" object does not exist in MVC. MVC controls can accept parameters and render HTML.

Categories : Asp Net Mvc



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