This is a migrated thread and some comments may be shown as answers.

Dynamically create page

2 Answers 50 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Peny
Top achievements
Rank 1
Peny asked on 04 Jul 2011, 10:25 AM
Hello,

I would like to make a page which content will change based on some criteria. For example the page will have a dropdown list and when the user selects the value "1" the page will contain a raddatetimepicker and a textbox. Or when the user selects the value "2" from the dropdown list,the page will contain 3 textboxes and 3 labels.

Could you please help me on that?Which approach should i use?

Regards,
Peny

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Jul 2011, 11:49 AM
Hello Peny,

One suggestion is to pass the combobox selected value as a query string. Then create the controls based on the query string value.

Sample code:
protected void Page_Load(object sender, EventArgs e)
{
     if((Request.QueryString["Control"] = "1"))
     {
       createDropDown();
     }
    else
     {
      createTextBoxes();   
     }
}

Thanks,
Shinu.
0
Peny
Top achievements
Rank 1
answered on 04 Jul 2011, 12:26 PM
Hello,

thanks for your reply!

I would also like to tell you,that the controls that will be loaded (based on the selection) will be a combination of controls stored in a db.
More detailed, i have a table that contains controls that are required for a selection. The table  contains: the name of the control and the type of the control. For example :
"Birth Date" , RadDateTimePicker
"Name/Surname",TextBox .
So based on the user's selection i want to load a combination of the controls stored in the db.

Could you please help me on that?

Regards,
Peny
Tags
General Discussions
Asked by
Peny
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Peny
Top achievements
Rank 1
Share this question
or