Welcome Guest Search | Active Topics | Sign In | Register

Vista FindControl Not Working Options
Mackin
Posted: Tuesday, September 11, 2007 10:26:44 AM
Rank: Advanced Member
Groups: Member

Joined: 6/1/2007
Posts: 31
Just upgraded to Vista and now when trying to access elements with the FindControl inside your Dialog boxes items are not found.

<asp:UpdatePanel ID="UpdatePanel6" runat="server">
<ContentTemplate>
<eo:Dialog ID="SchoolNameDL"
runat="server"
Height="60px"
Width="376px"
AllowResize="True"
BorderColor="#335C88"
BorderStyle="Solid"
BorderWidth="1px"
CloseButtonUrl="00070101"
ControlSkinID="None"
HeaderHtml="School Name"
MinimizeButtonUrl="00070102"
ResizeImageUrl="00020014"
RestoreButtonUrl="00070103"
ShadowColor="LightGray"
ShadowDepth="3"
BackShadeColor="LightGray"
BackShadeOpacity="35">
<ContentTemplate>
<table id="NewSchoolTbl" runat="Server">
<tr>
<td>Name:</td>
<td style="width:20px;"></td>
<td style="width: 306px"><asp:TextBox ID="NewSchoolName" runat="server" Width="270px"></asp:TextBox></td>
</tr>
<tr>
<td valign="top"></td>
<td style="width:20px;"></td>
<td style="width: 306px">
<asp:Button ID="AddSchoolName" runat="server" Text="Add Name" OnClick="AddSchoolName_Click" />
</td>
</tr>
</table>
</ContentTemplate>
<HeaderStyleActive CssText="padding-right: 4px; padding-left: 4px; font-size: 11px; background-image: url(00070104); padding-bottom: 3px; padding-top: 3px; font-family: tahoma" />
<FooterStyleActive CssText="background-color: #e5f1fd; padding-bottom: 8px;" />
<ContentStyleActive CssText="border-top: #335c88 1px solid; background-color: #e5f1fd" />
</eo:Dialog>
</ContentTemplate>
</asp:UpdatePanel>


Code Behind
protected void AddSchoolName_Click(object sender, EventArgs e)
{
TextBox NewSchoolName = (TextBox)SchoolNameDL.FindControl("NewSchoolName");
string TmpSchoolName = NewSchoolName.Text;
}

Error Message
Object reference not set to an instance of an object
eo_support
Posted: Tuesday, September 11, 2007 10:44:18 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

The issue has nothing to do with Vista. In order to do find controls inside ContentTemplate you would need to use:

SchoolNameDL.ContentContainer.FindControl("NewSchoolName");

Thanks
Mackin
Posted: Tuesday, September 11, 2007 10:53:58 AM
Rank: Advanced Member
Groups: Member

Joined: 6/1/2007
Posts: 31
eo_support,

Thanks for the quick reply. That did fix my problem but I did not have to do this until I upgraded to Vista. I'll scan my project and update all my references.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.