Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find control within ContentPlaceholder and placeholder?

I am adding controls dynamically to PlaceHolder which within ContentPlaceHolder

var t = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
var t1 = (PlaceHolder)mpContentPlaceHolder.FindControl("PlaceHolderName");

var t2 = (DropDownList)t1.FindControl("ControlID");

It looks like I am missing something because t2 is always null

like image 667
MasterPiece Avatar asked Sep 23 '10 18:09

MasterPiece


1 Answers

If you want to find controls of master page then you can find like :

Label l = Master.FindControl("label1") as Label;

And in your case for finding control from contentplaceholder you can find control like :

  TextBox TB=
  Master.FindControl("ContentPlaceHolder1").FindControl("textbox1") as
  TextBox;
like image 67
Finisher001 Avatar answered Sep 28 '22 03:09

Finisher001