dynamic-controls

How to persist a dynamic control (c#)

久未见 提交于 2019-12-01 10:47:28
问题 As per the title, I have created a custom control. On a certain button click event, this control is instantiated, then added to the page. It is a dynamic control, with it's own button events. In order for these button events to be triggered, the control must be drawn by the end of Page_Load / OnLoad , in the subsequent page_load / onload lifecycle stage. My problem is how do I persist this control? I cant store it in the Session object because it contains non-serializable items. 回答1: You

Dynamically created controls causing Null reference

别等时光非礼了梦想. 提交于 2019-12-01 02:24:13
I am trying to dynamically create controls and give them properties during run time. I have put my code inside the Page_Init event, when I run my website I can see my controls but when I click on the submit button an error occurrs saying "Object reference not set to an instance of an object". Here is the code I have used: //Creates instances of the Control Label FeedbackLabel = new Label(); TextBox InputTextBox = new TextBox(); Button SubmitButton = new Button(); // Assign the control properties FeedbackLabel.ID = "FeedbackLabel"; FeedbackLabel.Text = "Please type your name: "; SubmitButton.ID

Removing dynamic controls from panel

一曲冷凌霜 提交于 2019-11-29 09:13:42
I have dynamically generated controls on the panels of windows form and i have also generated a button for removing the controls, all in rows. int c = 0; private void button1_Click(object sender, EventArgs e) { int v; v = c++; panel1.VerticalScroll.Value = VerticalScroll.Minimum; ComboBox combo = new ComboBox(); combo.Name = "combobox" + v ; combo.Location = new Point(30, 5 + (30 * v)); ComboBox combo2 = new ComboBox(); combo2.Name = "combobox2" + v ; combo2.Location = new Point(170, 5 + (30 * v)); TextBox txt = new TextBox(); txt.Name = "txtbx" + v; txt.Location = new Point(300, 5 + (30 * v))

Dynamic created controls inside UpdatePanel?

為{幸葍}努か 提交于 2019-11-27 20:54:24
I want to create control that will allow user to design his own website structure. I imagined that inside UpdatePanel is control(s) with TextBox ( for page name) and Button 'add below'. It would looks like: | "Questions" | | [ add below ] | | "Tags" | | [ add below ] | | "Badges" | | [ add below ] | now when user click on button in "Tags" element there should appear new one, between "Tags" and "Badges", with editable name, so user can name it "Users" for example. It should be done without full postback ( to avoid page blinks). Now is my problem: I cannot load those controls (at last not all of

Removing dynamic controls from panel

♀尐吖头ヾ 提交于 2019-11-27 06:37:01
问题 I have dynamically generated controls on the panels of windows form and i have also generated a button for removing the controls, all in rows. int c = 0; private void button1_Click(object sender, EventArgs e) { int v; v = c++; panel1.VerticalScroll.Value = VerticalScroll.Minimum; ComboBox combo = new ComboBox(); combo.Name = "combobox" + v ; combo.Location = new Point(30, 5 + (30 * v)); ComboBox combo2 = new ComboBox(); combo2.Name = "combobox2" + v ; combo2.Location = new Point(170, 5 + (30

Dynamically Change User Control in ASP.Net

我是研究僧i 提交于 2019-11-27 04:26:33
I'm trying to create a web page that will display an appropriate user control based on the selected value of a drop down list. Basically the page layout is this: Drop Down Selection < User Control created based on drop down selection > I have it half working... the controls are changing when the selection changes. In OnInit(), I dynamically create the last selected control (whose value gets saved in session state because ViewState isn't available at OnInit). When the drop down selection change occurs, I remove the old user control, and add a new one. The problem is: with the new control being

Dynamic created controls inside UpdatePanel?

不打扰是莪最后的温柔 提交于 2019-11-26 20:29:24
问题 I want to create control that will allow user to design his own website structure. I imagined that inside UpdatePanel is control(s) with TextBox ( for page name) and Button 'add below'. It would looks like: | "Questions" | | [ add below ] | | "Tags" | | [ add below ] | | "Badges" | | [ add below ] | now when user click on button in "Tags" element there should appear new one, between "Tags" and "Badges", with editable name, so user can name it "Users" for example. It should be done without

Dynamically Change User Control in ASP.Net

╄→гoц情女王★ 提交于 2019-11-26 11:12:02
问题 I\'m trying to create a web page that will display an appropriate user control based on the selected value of a drop down list. Basically the page layout is this: Drop Down Selection < User Control created based on drop down selection > I have it half working... the controls are changing when the selection changes. In OnInit(), I dynamically create the last selected control (whose value gets saved in session state because ViewState isn\'t available at OnInit). When the drop down selection