Microsoft KB Archive/310301

= PRB: Header and Footer Templates Are Rendered Differently in Web User Controls =

Article ID: 310301

Article Last Modified on 6/14/2002

-

APPLIES TO


 * Microsoft Mobile Internet Toolkit 1.0

-



This article was previously published under Q310301



SYMPTOMS
When you are using a Web user control that contains a DeviceSpecific control with a header and a footer template, the header and footer template is not rendered in the correct place when you browse the page. Instead, the templates are rendered in the location where you place the user control in a mobile Web Forms page instead of in the header and footer locations of the Web Form.



RESOLUTION
To resolve this behavior, instead of a DeviceSpecific control, use an external style sheet that contains a header and a footer template.

The following code sample is an example of a Web user control that contains a mobile style sheet: <%@ Register TagPrefix=&quot;mobile&quot; Namespace=&quot;System.Web.UI.MobileControls&quot; Assembly=&quot;System.Web.Mobile&quot; %>      WML Header Template   WML Footer Template   <Choice Filter=&quot;isHTML32&quot;>  <mobile:Label id=Label1 runat=&quot;server&quot;>HTML Header Template</mobile:Label> </HeaderTemplate>  <mobile:Label id=&quot;Label2&quot; runat=&quot;server&quot;>HTML Footer Template</mobile:Label> </FooterTemplate> </Choice> </DeviceSpecific> </Style> </mobile:StyleSheet> The following code sample is an example of a mobile Web Form that uses an external style sheet: <%@ Page language=&quot;c#&quot; Inherits=&quot;System.Web.UI.MobileControls.MobilePage&quot; %> <%@ Register TagPrefix=&quot;mobile&quot; Namespace=&quot;System.Web.UI.MobileControls&quot; Assembly=&quot;System.Web.Mobile&quot; %> <mobile:Form id=&quot;Form1&quot; runat=&quot;server&quot; StyleReference=&quot;myHeaderStyle&quot;> <mobile:Label id=&quot;Label3&quot; runat=&quot;server&quot;>Some Content</mobile:Label> </mobile:Form> <mobile:StyleSheet id=&quot;StyleSheet1&quot; runat=&quot;server&quot; ReferencePath=&quot;myStyles.ascx&quot;> </mobile:StyleSheet>

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce the Behavior
<ol> <li> Add the following code to a Web User control (which is named ucTemplates.ascx) on your Web server: <%@ Control Inherits=&quot;System.Web.UI.UserControl&quot; Language=&quot;C#&quot; %> <%@ Register TagPrefix=&quot;mobile&quot; Namespace=&quot;System.Web.UI.MobileControls&quot; Assembly=&quot;System.Web.Mobile&quot; %> <mobile:DeviceSpecific id=&quot;DeviceSpecific1&quot;> <Choice Filter=&quot;isWML11&quot;>  <mobile:Label id=&quot;Label1&quot; runat=&quot;server&quot;>WML Header Template</mobile:Label> </HeaderTemplate>  <mobile:Label id=&quot;Label2&quot; runat=&quot;server&quot;>WML Footer Template</mobile:Label> </FooterTemplate> </Choice> <Choice Filter=&quot;isHTML32&quot;> <HeaderTemplate runat=&quot;server&quot;> <mobile:Label id=&quot;Label3&quot; runat=&quot;server&quot;>HTML Header Template</mobile:Label> </HeaderTemplate>  <mobile:Label id=&quot;Label4&quot; runat=&quot;server&quot;>HTML Footer Template</mobile:Label> </FooterTemplate> </Choice> </mobile:DeviceSpecific> </li> <li> Add the following code to a mobile Web Form (an .ascx file) on your Web server: <%@ Page language=&quot;c#&quot; Inherits=&quot;System.Web.UI.MobileControls.MobilePage&quot; %> <%@ Register TagPrefix=&quot;mobile&quot; Namespace=&quot;System.Web.UI.MobileControls&quot; Assembly=&quot;System.Web.Mobile&quot; %> <%@ Register TagPrefix=&quot;myControl&quot; TagName=&quot;Templates&quot; SRC=&quot;ucTemplates.ascx&quot; %> <mobile:Form id=&quot;Form1&quot; runat=&quot;server&quot; > <mobile:Label id=&quot;Label3&quot; runat=&quot;server&quot;>Some Content</mobile:Label> <myControl:Templates runat=&quot;server&quot;></myControl:Templates> </mobile:Form> </li> <li> Use the following code to create a Web.config file at the root of your Web application: <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?> <system.web> <deviceFilters> <filter name=&quot;isHTML32&quot; compare=&quot;preferredRenderingType&quot; argument=&quot;html32&quot; /> <filter name=&quot;isWML11&quot; compare=&quot;preferredRenderingType&quot; argument=&quot;wml11&quot; /> </deviceFilters> </system.web> When you browse the .aspx page, you see that both the WML and HTML headers and footers are generated and placed incorrectly in the .aspx page. </li></ol>

Additional query words: UserControl User-Control DeviceSpecific Device Specific

Keywords: kbnofix kbdevicespecific kbtemplate kbprb kbservercontrols KB310301

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.