Questions tagged [dynamic-usercontrols]

Programmatically created instances of any server control

79 questions
1
vote
0 answers

C# Update Text of dynamically generated UserControl label

I'm really struggling with C#. I've been given a project to work on, but most of my experience is in C. The purpose of the application is to ping an API and display the data from it in a windows form. I can get the data, and dynamically display it,…
1
vote
1 answer

Dynamically Load UserControl using MVVM Light Toolkit

I searched this site and i found 2 Links how to load wpf usercontrol in MVVM pattern MVVM-Light: Load UserControl into Window but still i cant find the answer to my problem and this link MVVM-Light Locator Pattern and Reusable UserControl i Didn't…
Ankesh
  • 4,847
  • 4
  • 38
  • 76
1
vote
1 answer

Nested ASP.NET user control is null

I am developing an ASP.NET application using Visual Studio 2017 and .NET 4.7.1. I have a simple user control, named ContentStatsViewer.ascx, that that displays a couple of labels. The values to display are passed through public properties. Other…
CesarGon
  • 15,099
  • 6
  • 57
  • 85
1
vote
1 answer

How to get a user control's type given its path

Is there a way to translate a path to a user control, ~/usercontrols/MyUserControl.ascx, to a type, as in typeof(MyUserControl)?
Mr Bell
  • 9,228
  • 18
  • 84
  • 134
1
vote
3 answers

How to load user control given its type

Is there a way to instantiate and use a usercontrol (.ascx) if given you have its Type (ie. typeof(MyUserControl))? With regular asp.net controls like a textbox or a dropdownlist you can just make a new instance and add it to a controls collection. …
Mr Bell
  • 9,228
  • 18
  • 84
  • 134
1
vote
1 answer

how to use OutputCache in a userControl in asp.net

I have a aspx page that have this piece of code to load a usercontrol loaded from database Control userControl = new Control(); userControl = LoadControl(userControlName); ((HiddenField)userControl.FindControl("HiddenFieldCategoryID")).Value =…
Mariam
  • 533
  • 2
  • 12
  • 22
1
vote
2 answers

Trying to dynamically add a button with a unique identity in DataGridView for each row

I have been trying to do the said above things with this code: protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { //Populating a table from the database SqlConnection con = new…
1
vote
0 answers

Change ControlTemplate dynamically

There is a template: It consists of a UserControl. I…
1
vote
0 answers

How to set a default behaviour for MouseUp event in all my custom User Controls

I'm working on a feature that allows users to add different types of control to a panel(picturebox, label, textbox, button), also this controls should be "moveable" over the panel. To approach this, I've created(with help of other answers) a custom…
4D1C70
  • 490
  • 3
  • 10
1
vote
0 answers

How to re-use already bound data in a user control on post back

I have a user control that I dynamically add to a Panel. I also have a couple of other functionality in the aspx page like search which is inside an update panel that causes the page to post back. From what I have read so far is that dynamic control…
thebenman
  • 1,621
  • 14
  • 35
1
vote
1 answer

DropDownList in User Control loses SelectedValue on first postback when loaded dynamically

I have an ASPX page that has a PlaceHolder in which User Controls are loaded dynamically. HTML markup is as follows: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="Test" %>
Sheldon Cooper
  • 627
  • 4
  • 15
1
vote
0 answers

Is it possible to use AForge libraries in Windows Forms Control Library?

I have a Windows Forms Control Library called "UserControlTest" (I'm practicing with it right now) and I am trying to use some of the AForge Libraries Controls on it. It lets me put them on the design and doesn't have any errors after building the…
user3634308
  • 119
  • 1
  • 3
  • 14
1
vote
1 answer

UserControl DropDownList loses its selection

I have a user control with a DropDownList with AutoPostBack = true, also I have an aspx page to display this control. I re-create user control in OnInit method of the page protected override void OnInit(EventArgs e) { base.OnInit(e); var…
1
vote
1 answer

ASP dynamic usercontrols in a gridview do not update

I have a got Gridview, that gets its data by: internal void updateGrid() { List data = dt.getAlldata(UserID(), ListID()); gridViewer.DataSource = data; gridViewer.DataBind(); } After a button click the database is updated and…
Tagamoga
  • 332
  • 4
  • 18
1
vote
2 answers

Dynamic-usercontrol click event

UserControl: private string lastName; public string LastName { get { return lastName; } set { lastName = value; lastNameTextBox.Text = value; } } Form: using (SqlConnection myDatabaseConnection = new…
Karlx Swanovski
  • 2,869
  • 9
  • 34
  • 67