dynamic-controls

Add dynamic controls in ASP.NET, is there a difference between 1.1 and 2.0?

风格不统一 提交于 2019-12-18 13:44:49
问题 I am pretty sure back in the days of ASP.NET 1.0/1.1, controls created during runtime needs to be added before Page_Load event of the Page Lifecycle (i.e. inside Page_Init ). Here's one article by Microsoft on it (for .NET 1.0/1.1): HOW TO: Dynamically Create Controls in ASP.NET: Note When you create dynamic controls on a Web Form, you must create the controls and add them to the controls collection in either the Page_Init event handler or the Page_Load event handler. Otherwise, the controls

Adding dynamic controls to MVC and getting their values in Controller

爷,独闯天下 提交于 2019-12-13 21:09:05
问题 Sorry for making it too long but you can see actual problem to get issue. Background: Its a e-commerce project where I am allowing client to add any number of categories and subcategories under that. For each category client will create some attributes by himself. Suppose client created a category Mobile Phones and this category is added to Category table and then he creates some attributes to that category like Price , Brand etc and all these attributes are inserted into Attributes table

Postback problem for my custom control load wizard

匆匆过客 提交于 2019-12-13 20:09:17
问题 I have some problem that happens when controls are loaded in init and it still doesn't help me to get proper postback event fired on time. I am trying to create a rich wizard control that will enable switching, links with description, completely customized steps, integration of substeps - by using dynamic control load that is avoids standard asp.net wizard way of loading. Idea is to have on left part navigation, on right part content, or substeps that are run from right part and that go over

Add controls dynamically in flowlayoutpanel

孤者浪人 提交于 2019-12-13 12:23:41
问题 In a windows form, I can add control dynamically by doing this: for (int i = 0; i < 5; i++) { Button button = new Button(); button.Location = new Point(160, 30 * i + 10); button.Tag = i; this.Controls.Add(button); } How do I add controls dynamically in a FlowLayoutPanel ? 回答1: For a FlowLayoutPanel , you don't need to specify a location since the controls are arranged for you. Just change " flowLayoutPanel1 " to the name of your FlowLayoutPanel : for (int i = 0; i < 5; i++) { Button button =

How can i create dynamic button click event on dynamic button - VB.net

牧云@^-^@ 提交于 2019-12-13 08:25:07
问题 I am creating a button on page dynamically. now i want to use button click event on that button. How can i do this in VB.net & asp.net? My code: Page Load: Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Try LoadControls() Catch ex As Exception End Try End Sub Load Controls Private Sub LoadControls() Try Dim ButtonTable As New HtmlTable Dim ButtonTableRow As New HtmlTableRow Dim ButtonTableCell As New HtmlTableCell Dim btnCode As New Button btnCode.ID = "btnCode"

Dynamically Create controls and save the controls values across postback - ASP.Net C#

筅森魡賤 提交于 2019-12-12 11:09:35
问题 Consider this - I allow the end user to create a tab control dynamically in an ASP.Net page by getting some details. For each and every tab added I get some settings - Tab Title Tab Content Tab Footer link So I get these details for each and every tab. The user is provided with a button 'Add Tab' to more one more tab. So I need to add one more tab settings panel in the page to get the tab settings. But doing so, I lose the values entered in the previously created dynamic tab settings panel.

.NET 4.5 WebForms: do I (still) really have to specify all 3 templates in a FormView?

帅比萌擦擦* 提交于 2019-12-12 08:06:24
问题 Investigating the new strongly-typed, model-binding approach within ASP.NET 4.5 WebForms: In Scott Hanselman's example of WebForms model binding (amongst others) I've seen the use of a FormView that opens in "Edit" mode, containing a number of DynamicControls e.g. <asp:FormView runat="server" ID="MyForm" ... DefaultMode="Edit"> <EditItemTemplate> <asp:DynamicControl runat="server" ID="Field1" DataField="Field1" Mode="Edit" /> <asp:DynamicControl runat="server" ID="Field2" DataField="Field2"

How to pull PostBack data into a dynamically added UserControl (.NET)?

纵饮孤独 提交于 2019-12-11 16:28:49
问题 I have a Panel on my Page: <asp:Panel ID="pnlTest" runat="server" /> Then I dynamically add a TextBox to it on Page_Load: TextBox simpleTextBox = new TextBox(); pnlTest.Controls.Add(simpleTextBox); simpleTextBox.ID = "SimpleTextBox-1"; Is there a way to pull in the information typed in this TextBox without pulling it directly from Request.Form? I thought I could do something like this after I added it again: lblPresentResults.Text = myTextBox.Text; I know this example seems contrived, but I

ASP.NET - How to dynamically generate Labels

◇◆丶佛笑我妖孽 提交于 2019-12-11 15:22:47
问题 I am doing a project on Flight Booking system. My part is to enter the details of the passengers travelling. These passengers may include Adults as well as children. So I need to dynamically generate separate labels and text boxes for all the passengers travelling so that details of all them can be entered. How can I do that? 回答1: You may want to look at GridViews / DetailsView / Repeaters etc. You can then write some databinding code to show the different labels for each record as required.

C# - Creating controls dynamically and accessing them

爷,独闯天下 提交于 2019-12-11 11:57:34
问题 I'm creating a simple notepad type of application with the tab functionality. I'm creating the TabControl, its TabPages and RichTextBoxes at run-time. I have them instantiated at class scope. And there is a MenuStrip item called New, by clicking that you can add more tab pages. TabControl tbcEditor = new TabControl(); TabPage tbPage = new TabPage(); RichTextBox rtb = new RichTextBox(); private void frmTextEditor_Load(object sender, EventArgs e) { Controls.Add(tbcEditor); tbcEditor.Dock =