Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
On My form Asp, I create a TextBox using the code without drak and drop method( cause i need to create a flexible form create a text box by calling a method (CreatetextBox)from the class (Web user Control Class)):
The Problem is :
When the user fill The Text Box and press Save for exemple i need to get the value of this custom TextBox

Thx in advance
Posted
Updated 28-Mar-12 21:11pm
v2

HI , try this
C#
foreach (Control ctrl in form1.Controls)
        {
            if (ctrl is TextBox)
            {
                //here you can store the value of textbox
                string StoreValueToDB = ((TextBox)ctrl).Text;

            }
            if (ctrl is DropDownList)
            {
                //here you can store the value of textbox
                string StoreValueToDB = ((DropDownList)ctrl).SelectedValue;
            }
        }
    }
 
Share this answer
 
Comments
bashar Haydar 29-Mar-12 3:42am    
I try this before, but the problem is that the TextBox (ctrl) is a LitralControl
FINALLY AFTER # DAYS OF SEARCH I FIND THE SOLUTION :

result.TextBoxValue = Request.Form["TB_0$ctl01"];
TB_0$ctl01: THE KEY OF MY CUSTOM TEXT BOX IS TB_0 AND THE DEBUGGUER BY DEFAULT ADD $ctl01 TO DON'T CONFUSE IF I FORGUET TO MODIFY THE ID

HAVE A NICE PROGRAMMING DAY PEUFFFFFFFFFFFFFF
 
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