Findcontrol is not working !!! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Findcontrol is not working !!!

papillonx101papillonx101 Posts: 1Member
Can someone tell me what I am doing wrong?
Initialy I set Visible property of some of the controls in my ASPX to false.
I am reading table which has the IDs of the controls in my particular ASPX page.
Then I iterate in my list and if the ID of control is the same in table and page I
will set controls property visible to true in my ASPX page for the control I find in page otherswise do nothing.

The list is well populated but I dont understand why the program is always jumping
on **else block

Any idea?
Thanks in advance and here is my code.

private void ShowControls()
SecurityList tempList = new SecurityList();
SecurityList sec = new SecurityList();

string AppID = "INOUT"; //This will come from the DB in future
string UserID = "joe"; //This will come from the DB in future
string PageID = "10"; //This will come from the DB in future

tempList = SecurityManager.GetList(sec,AppID,UserID,PageID);

foreach (Security loop in tempList)
Control c = FindControl(loop.ControlID.ToString());
if ((c!=null))
c.Visible = true;
Response.Write("Found"); // only for test

Response.Write("Not Found"); // only for test



  • mohitkumarmohitkumar indiaPosts: 14Member

    I think before find control you have to use the id of the control from which you wanted to find the controls for ex:
    div.findcontrol(id of the control)

    For similar kind of c# interview questions you can refer this link

Sign In or Register to comment.