Click here to Skip to main content
16,010,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Get textBox Value Created Into Custom Control from Post Back(I need To Get value of This Text Box)

in aspx.cs
protected override void OnLoad(EventArgs e)
{
if (!IsPostBack)
{
CreateTextBoxControls();
}

DisplayResult();
}
private AspControlFinal.Controls.TextBoxControl CreateTextBoxControl(int id)
{


result = (AspControlFinal.Controls.TextBoxControl)LoadControl("~/Controls/TextBoxControl.ascx");
result.ID = "TB_" + id;
result.InsertBellow += InsertRowBellow;
result.Remove += RemoveRow;

result.CreateTextBox("What's your name?");
m_controls[id] = result;
return result;
}
private void CreateTextBoxControls()
{
ArrayList ids = ControlIdList;

if (ids != null)
{
foreach (int id in ids)
{
AspControlFinal.Controls.TextBoxControl control = CreateTextBoxControl(id);

c_placeHolder.Controls.Add(control);

}
}
}

in acsx.cs :
TextBox TextBox1=new TextBox();
Label Label1=new Label1();
public String TextBoxValue
{
get
{
return TextBox1.Text;
}
set
{
TextBox1.Text = value;
}
}

public void CreateTextBox(string Question)
{
LabelValue = Question;

TextBox1.ID = "TextBox1";
Page.Form.Controls.Add(Label1);
Page.Form.Controls.Add(new LiteralControl("
"));
Page.Form.Controls.Add(TextBox1);
Page.Form.Controls.Add(new LiteralControl("
"));

}
Posted
Updated 28-Mar-12 2:56am
v2
Comments
Mohamed Mitwalli 28-Mar-12 8:38am    
some code will be useful .

1 solution

Use FindControl method of Custom Control object.
FindControl accepts a parameter i.e. Child Control Name(Textbox).


I hope it helps you.
 
Share this answer
 
Comments
bashar Haydar 28-Mar-12 9:07am    
Can you put an exemple

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