Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In this code How I find Textbox10 id on runtime because this is runtime generate textbox .

I want to save record which I entered on textbox .....

Dear Team help me....

I have big issue......


RadioButton rdbuttn;
        CheckBox chkList1;
        TextBox txtbox;
        int value = Convert.ToInt32(ddlNumberofAnswer.SelectedValue);
        if (ddlAnswerType.SelectedValue == "2")
        {
            ddlNumberofAnswer.Enabled = true;
            txtTextBox.Visible = false;
            try
            {
                for (int intControlIndex = 0; intControlIndex < value; intControlIndex++)
                {
                    chkList1 = new CheckBox();
                    txtbox = new TextBox();
                    chkList1.ID = "Chk" + intControlIndex;
                    txtbox.ID = "TextBox1" + intControlIndex;
                    chkList1.Font.Name = "Verdana";
                    chkList1.Font.Size = 9;
                    pnlPanel.Controls.Add(chkList1);
                    pnlPanel.Controls.Add(new LiteralControl("<br>"));
                    pnlPanel.Controls.Add(txtbox);
                    pnlPanel.Controls.Add(new LiteralControl("<br>"));
                }
            }
            catch (Exception exp)
            {
                throw new Exception(exp.Message);
            }


[Edited]Code is wrapped in "pre" tags[/Edited]
Posted
Updated 11-Jul-11 3:02am
v2
Comments
Rohitsingh.icfai 11-Jul-11 9:00am    
I use find control but not working.
But question where are u find this id.

One more thing on ViewSource HTML code also there are not runtime Textbox ID not generate..

Have a look at the FindControl method[^].
 
Share this answer
 
One thing you have to remember is ,the data and the textbox will be lost in the post back depending on where you have created your textbox. You can refer this link , which shows different scenarios in creating dynamic controls.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900