[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

Can't get reference to user control within device-specific template

MichealH

11/1/2002 10:14:00 PM

I'm having trouble getting programmatic access (page behind) to my user
control when it is declared within a DeviceSpecific\Choice\ContentTemplate
node, and wonder if someone can provide me with the correct C# syntax.
Everything works fine if I move the user control element outside the
device-specific markup.

Assume I have valid registration of the ASCX namespace and tag name, so that
the following works fine as an immediate child of the mobile:Form element:

<mobile:Form id="form1" runat="server">
<foo:bar runat="server" id="MyControl" />
</mobile:Form>

Within the Page_Load handler, I can easily reference this element using [
namespace ] MyControl.

When I nest the user control in a device specific template (below), I cannot
determine the correct syntax to get a reference to the control. I get null
exception errors. Using FindControl("MyControl") on its ancestors doesn't
do the trick. I assume I need to address it as a child of the
DeviceSpecific node or one of its children, but can't determine how that's
done.

<mobile:Form id="form1" runat="server">
<mobile:DeviceSpecific runat="server">
<Choice Filter="isHTML32">
<ContentTemplate>
<foo:bar runat="server" id="MyControl" />
</ContentTemplate>
</Choice>
</mobile:DeviceSpecific>
</mobile:Form>

Help? Thanks.

MichealH