runtime generation of controls and their text
-
hi friends i have a button on the click of which i get textboxes.. say at one time i want 2 textboxes and the next time i want 3 textboxes and may be next time i want 1 textbox ... and then i choose anyoption from the dropdownlist say the options in the dropdownlist is: as checkboxes as radiobuttons as a select menu dont display it and i choose any one may be checkbox or may be radio buttons and click on another button(save button) now on my new aspx page i need the options entered in the textboxes to be accompanied by the options from the dropdownlist say checkbox or radiobuttons hope you got my question now... K.Gayathri
-
hi friends i have a button on the click of which i get textboxes.. say at one time i want 2 textboxes and the next time i want 3 textboxes and may be next time i want 1 textbox ... and then i choose anyoption from the dropdownlist say the options in the dropdownlist is: as checkboxes as radiobuttons as a select menu dont display it and i choose any one may be checkbox or may be radio buttons and click on another button(save button) now on my new aspx page i need the options entered in the textboxes to be accompanied by the options from the dropdownlist say checkbox or radiobuttons hope you got my question now... K.Gayathri
What is your question?
No comment
-
What is your question?
No comment
i have a button on the click of which textboxes will appear and i have a dropdownlist which has the options as: as checkboxes as radiobuttons as a select menu dont display it if i click the button say 5 times 5 textboxes will appear and i type in one,two,three,four,five and choose radiobuttons from the dropdownlist and click save button in that page it should redirect to another aspx page where i will have one,two,three,four,five along with radiobuttons for each... so how to do it... K.Gayathri
-
i have a button on the click of which textboxes will appear and i have a dropdownlist which has the options as: as checkboxes as radiobuttons as a select menu dont display it if i click the button say 5 times 5 textboxes will appear and i type in one,two,three,four,five and choose radiobuttons from the dropdownlist and click save button in that page it should redirect to another aspx page where i will have one,two,three,four,five along with radiobuttons for each... so how to do it... K.Gayathri
You can create controls in your code and add them to the page dynamically This assumes you are passing the number of controls to create and the type of control (as an int) to the page.
void CreateControls()
{
int numberOfControls = Request["numberOfCtrls"];
switch(Convert.ToInt32(Request["ctrlType"]))
{
case 1:
for(int x = 0; x < numberOfControls; x++)
{
RadioButton ctrl = new RadioButton();
... set any properties ...
Controls.Add(ctrl);
}
break;
case 2:
...
}
}
No comment
-
You can create controls in your code and add them to the page dynamically This assumes you are passing the number of controls to create and the type of control (as an int) to the page.
void CreateControls()
{
int numberOfControls = Request["numberOfCtrls"];
switch(Convert.ToInt32(Request["ctrlType"]))
{
case 1:
for(int x = 0; x < numberOfControls; x++)
{
RadioButton ctrl = new RadioButton();
... set any properties ...
Controls.Add(ctrl);
}
break;
case 2:
...
}
}
No comment
hi friends i have created the controls but dont know how to get the value from such controls can anyone help me plz... //code to create the dynamic textboxes protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Session["Count"] = "0"; } } protected void lnkAddGroup_Click(object sender, EventArgs e) { int i = Convert.ToInt32(Session["Count"].ToString()); int k = 0; for (k = 0; k <= i; k++) { TextBox txt = new TextBox(); txt.ID = "DynamiceTextbox" + Convert.ToString(k); //txt.Text = "" ; ImageButton img = new ImageButton(); img.ID = "DynamicDeletebutton" + Convert.ToString(k); img.ImageUrl = "~Images/delete_icon.jpg"; HtmlGenericControl lineBreak = new HtmlGenericControl("br"); PHGroupName.Controls.Add(txt); PHGroupName.Controls.Add(img); PHGroupName.Controls.Add(lineBreak); Session["Count"] = Convert.ToString(Convert.ToInt32(k + 1)); } } PHGroupName is the placeholder name.... K.Gayathri
-
hi friends i have created the controls but dont know how to get the value from such controls can anyone help me plz... //code to create the dynamic textboxes protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Session["Count"] = "0"; } } protected void lnkAddGroup_Click(object sender, EventArgs e) { int i = Convert.ToInt32(Session["Count"].ToString()); int k = 0; for (k = 0; k <= i; k++) { TextBox txt = new TextBox(); txt.ID = "DynamiceTextbox" + Convert.ToString(k); //txt.Text = "" ; ImageButton img = new ImageButton(); img.ID = "DynamicDeletebutton" + Convert.ToString(k); img.ImageUrl = "~Images/delete_icon.jpg"; HtmlGenericControl lineBreak = new HtmlGenericControl("br"); PHGroupName.Controls.Add(txt); PHGroupName.Controls.Add(img); PHGroupName.Controls.Add(lineBreak); Session["Count"] = Convert.ToString(Convert.ToInt32(k + 1)); } } PHGroupName is the placeholder name.... K.Gayathri
hi friends i am using the following code: int i = Convert.ToInt32(Session["Count"].ToString()); int k = 0; string[] strTextBoxValues = new string[] { }; for (k = 0; k <= i - 1; k++) { string textboxval = "DynamicTextbox" + Convert.ToString(k); TextBox textval = (TextBox)this.Page.FindControl(textboxval); textval.ID = textboxval; Response.Write(textval.Text); } but the findcontrol method returns null....and any one to help me in this issue as i am stuck in my work... K.Gayathri