I have a MasterPage, Content, and aspx page within the Content.
I need to find a control using the string ID of the control to be found.
<%@ Page Language="C#" MasterPageFile="~/MasterPa ge.master"
AutoEventWireup="true" CodeFile="UploadImage.aspx .cs"
Inherits="UploadImage" Title="Upload Images" Debug ="true" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head " Runat="Server">
<title>HoldemMyWay Helper</title>
<style type="text/css">
.style2
{
margin-right: 0px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Cont entPlaceHo lder" Runat="Server">
<b>HoldemMyWay Helper </b>
<asp:ImageButton ID="cmdc1Clip" runat="server" Height="32px"
ImageUrl="~/CardImages/c1C lip.gif" Width="25px" OnClick="cmdc1Clip_Click"/ > <br />
<br />
====
The following syntax compiles but returns a null value for the control.
and the following error:
Object reference not set to an instance of an object.
ImageButton MyControl = (ImageButton)this.Master.F indControl ("Content2 ").FindCon trol("Cont entPlaceHo lder").Fin dControl(" cmdc1Clip" );
What do you suggest?
Thank you,
Dovberman
Asked: 2012-03-10
so it would become FindControlRecursive(this.