How to find the asp control that is in the Mobile Web Form ContentTemplate from Code Behind? RRS feed

  • Question

  • User-1833521293 posted

    I created a Mobile Web Form using the <ContentTemplate> so I can use Standard asp controls instead of the Mobile Web Form controls.  Here is the HTML code: 

    <html xmlns="http://www.w3.org/1999/xhtml" >
        <mobile:Form id="Form1" runat="server">
        <mobile:Panel ID="Panel1" Runat="server">
        <mobile:DeviceSpecific ID="DeviceSpecific1" Runat="server">
            <Choice Xmlns="http://schemas.microsoft.com/mobile/html32template">
                <asp:Label ID="lblReportDate" runat="server" Font-Names="Arial" Font-Size="X-Small"
                    Text="Report Date:"></asp:Label> 
                <asp:TextBox ID="txtReportDate" runat="server" MaxLength="10" Font-Names="Arial" Font-Size="X-Small"></asp:TextBox>
     In Code Behind, it did not see txtReportDate directly.  So I tried 
    Dim txtReportDate As TextBox = Me.Panel1.DeviceSpecific.FindControl("txtReportDate") 
    Dim txtReportDate As TextBox = Me.Panel1.FindControl("txtReportDate")

      but both didn't find the textbox txtReportDate.  I need help to refer to the control in Code Behind.  Thanks.


    Wednesday, June 18, 2008 5:21 PM


  • User-1833521293 posted
    I figured it out and would like to share: 

    Dim txtReportDate As TextBox = Panel1.Content.FindControl("txtReportDate")


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 18, 2008 8:34 PM