A method on the Control class in the .NET framework that finds a control from its id. The control is only found if it is within the calling control's naming container.
Questions tagged [findcontrol]
374 questions
5
votes
1 answer
Finding a Control in a page from a page base class
Hope you're having a good Friday and stuff... okay, so here's my question:
All my ASPX pages inherit from a base class called BasePage. BasePage inherits from:
System.Web.UI.Page
Now, how do I access/set a control in my aspx page from my page…

Ev.
- 7,109
- 14
- 53
- 87
5
votes
3 answers
Using FindControl: Accessing Controls in a Formview
I'm developing a simple Wedding List application, where guests can reserve the present they want to buy for the bride and groom. The Reserve page wraps a few fields inside a couple of panels, all wrapped inside a FormView.
The user enters their…

CJM
- 11,908
- 20
- 77
- 115
5
votes
3 answers
findcontrol does not find dynamically added control which was just addes one line before
who can explain this to me?
CheckBox ckRequest = new CheckBox();
ckRequest.ID = "ckRequest";
ckRequest.DataBinding += new EventHandler(this.CkIsRequested_DataBinding);
container.Controls.Add(ckRequest);
Control con =…

Ephedra
- 831
- 10
- 24
5
votes
3 answers
.FindControl always returns null
I have two methods. The first creates one table dynamically, and I add that table into a PlaceHolder.
private void generateData(){
Table tbl = new Table();
tbl.ID = "table1";
holder_info.Controls.Add(tbl);
// ...adding tr's and…

oteal
- 614
- 2
- 13
- 25
4
votes
1 answer
FindControl() return null
I trying to create application whad add controlls dynamicaly. I have masterpage, my asp:Content is here:

cadi2108
- 1,280
- 6
- 19
- 43
4
votes
2 answers
asp.net FindControl Recursively
This is a really weird one - I will do my best to explain.
I have a basic master page:
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="master_MasterPage" %>

John
- 772
- 7
- 17
4
votes
2 answers
Find control in RoleGroup of LoginView
I have some textboxes and checkboxes inside a RoleGroup of a LoginView. How can I access these controls in my code-behind?
…

Dukebaby
- 204
- 4
- 13
4
votes
2 answers
FindControl in RowDataBound-Event ends in error
My TemplateField in my GridView was created like this:
user6886412
4
votes
3 answers
Trouble with FindControl and dynamicly created controls
Example code:
var div = new HtmlGenericControl("div");
div.Controls.Add(new Literal() { ID = "litSomeLit" });
var lit = (Literal)div.FindControl("litSomeLit");
Assert.IsNotNull(lit);
This code fails the assert, because lit is null. …

Fishtoaster
- 1,809
- 2
- 20
- 36
4
votes
1 answer
Find control in repeater footer returns null for text box
I have two nested repeaters. In the nested one's footer I have text box and file upload controls. I was able to get an instance of the file upload without any problem, but the instance of the text box is null, though both are placed in the footer.…

Dania
- 1,648
- 4
- 31
- 57
4
votes
2 answers
Problem finding a control within a FormView from code-behind
Here the code behind... I'm trying to retrieve this control so I can add items to the drop down list (I'm retrieving the Role Groups to add to the drop down list in the code-behind)
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As…

Matt
- 5,249
- 12
- 40
- 45
3
votes
1 answer
How do I find a ClientId of control in a Listview?
This question is very similar to
How do I find the Client ID of control within an ASP.NET GridView?
However I'm using a listview and a label:

Gio
- 4,099
- 3
- 30
- 32
3
votes
3 answers
FindControl - can't find dropdownlist
I have a dropdownlist:
A nice little one. I have some code to find it:
DropDownList myControl1 = (DropDownList)Page.FindControl("ddlGoalKeeper");
Not.. it's…

Oedum
- 796
- 2
- 9
- 28
3
votes
4 answers
How to find user control of an ASP.NET page inside of event of another user control on that ASP.NET page EDIT: different content placeholders?
I have a ASP.NET page with 2 user controls registered. The first one has only one button in it. The second one is simple text and hidden on default. What I want is to make the second one visible when the button in the first one is clicked (that is…

Janez
- 2,336
- 5
- 25
- 37
3
votes
1 answer