Table Control - how to recognize Text box

K

Krish

Hi,

I am using table control to create table/cell & 2 text box & one image
button during runtime. Onclick event of image button i would like to
validate if there is any value in either of text boxes, but my intellisense
will not recognize those textboxes created during runtime. How to overcome
this issue. Pl. help.

protected void Page_Load(object sender, EventArgs e)

{


TableCell cellDateRange = new TableCell();
cellDateRange.Text = "Date Range:From - To : ";

TableCell txtDtFromCell = new TableCell();
TextBox txtDtFrom = new TextBox();

TableCell txtDtToCell = new TableCell();
TextBox txtDtTo = new TextBox();

TableCell imgCell = new TableCell();
ImageButton imgSubmit = new ImageButton();
imgSubmit.ImageUrl = "..\\images\\view.gif";
imgSubmit.Click += new ImageClickEventHandler(ImgSubmit_Click);

row.Cells.Add(cellDateRange);
txtDtFromCell.Controls.Add(txtDtFrom);
row.Cells.Add(txtDtFromCell);
txtDtToCell.Controls.Add(txtDtTo);
row.Cells.Add(txtDtToCell);

imgCell.Controls.Add(imgSubmit);
row.Cells.Add(imgCell);
filTable.Rows.Add(row);

}

public void ImgSubmit_Click(object sender, ImageClickEventArgs e)

{

lblMessage.Text = "";

if txtDtFrom.Text == "") ======> i get error here intellisense cannont
understand txtDtFrom

{
}

}
 
K

Krish

Found answer by myself , thought it will be useful for the community

public void ImgSubmit_Click(){

TextBox i;

i = (TextBox)Page.FindControl("txtID");

if (!(i == null))

{

lblMessage.Text = i.Text;

}

else

{

lblMessage.Text = "not found";

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top