Device Filters

J

John Miller

I'm working with the Device-Specific Content quickstart
tutorials at
http://samples.gotdotnet.com/MobileQuickStart/
(nh3mssfx2ihebm551zmqjxff)/Default.aspx?
url=doc/DeviceSpecific.aspx

I've added the device filters to system.web element in
the web.config:

<system.web>
<deviceFilters>
<filter name="IsColor" compare="IsColor"
argument="true" />
<filter name="IsPocketIE" compare="Browser"
argument="Pocket IE" />
<filter name="IsHTML" compare="PreferredRenderingMIME"
argument="text/html" />
</deviceFilters>
</system.web>

and I've added device specific elements to an aspx page:

<mobile:Label runat="server" >
<DeviceSpecific>
<Choice Filter="IsPocketIE" Text="Running on Pocket
IE" />
<Choice Filter="IsHTML" Text="Running on other HTML
device" />
<Choice Text="Running on other device" />
</DeviceSpecific>
<mobile:Label>

When I build and run I get the error:

Can find neither a device capability named 'IsHTML32' nor
a public non-static method on the page named 'IsHTML32'
that returns a System.Boolean and takes
System.Web.Mobile.MobileCapabilities and System.String as
arguments.

What am I missing?

jMM
 
L

Lewis Wang [MSFT]

Hi John,

Thank you for your update. You may change "IsColor" to "isColor". Does it
work?

Hope this helps.

Best regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "John Miller" <[email protected]>
| Sender: "John Miller" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: Device Filters
| Date: Thu, 11 Sep 2003 10:50:13 -0700
| Lines: 135
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcN4jSb62UYwbVyzT8y9Y2kmNsCcRg==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.framework.aspnet.mobile
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.mobile:6229
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.mobile
|
|
| Hi Lewis,
|
| I added the method and it solved the problem. Thanks for
| the help.
|
| The Choice Element help topic states that "When
| evaluating the Choice element, a check is made to
| determine whether a method of the appropriate signature
| exists on the page. If not the <devicefilters> section of
| web.config is checked."
|
| It seems as if this check isn't being made and the page
| errors out before the web.config is checked.
|
| What do I need to do to be able to define the filters in
| the web.config.
|
| jMM
|
|
| >-----Original Message-----
| >Hi John,
| >
| >You may define public methods for the filters. For
| example:
| >
| >public bool IsHTML(System.Web.Mobile.MobileCapabilities
| capabilities,
| >String optionalArgument)
| >{
| > return true;
| >}
| >
| >When a device requests the page, the framework checks
| each defined <Choice>
| >tag in order. For each choice, it tests the filter
| specified by the filter
| >attribute. If the filter return true, that choice is
| picked.
| >
| >Please check the following link for more information.
| ><Choice> Element
| >http://msdn.microsoft.com/library/default.asp?
| url=/library/en-us/mwsdk/html/
| >mwlrfchoiceelement.asp
| >
| >Hope this helps.
| >
| >Best regards,
| >Lewis
| >This posting is provided "AS IS" with no warranties, and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "John Miller" <[email protected]>
| >| Sender: "John Miller" <[email protected]>
| >| Subject: Device Filters
| >| Date: Wed, 10 Sep 2003 10:19:19 -0700
| >| Lines: 44
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| Thread-Index: AcN3v6tqbxfRfNgfSV6tYQeagQ30zQ==
| >| Newsgroups:
| microsoft.public.dotnet.framework.aspnet.mobile
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| >microsoft.public.dotnet.framework.aspnet.mobile:6215
| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| >| X-Tomcat-NG:
| microsoft.public.dotnet.framework.aspnet.mobile
| >|
| >|
| >| I'm working with the Device-Specific Content
| quickstart
| >| tutorials at
| >| http://samples.gotdotnet.com/MobileQuickStart/
| >| (nh3mssfx2ihebm551zmqjxff)/Default.aspx?
| >| url=doc/DeviceSpecific.aspx
| >|
| >| I've added the device filters to system.web element in
| >| the web.config:
| >|
| >| <system.web>
| >| <deviceFilters>
| >| <filter name="IsColor" compare="IsColor"
| >| argument="true" />
| >| <filter name="IsPocketIE" compare="Browser"
| >| argument="Pocket IE" />
| >| <filter name="IsHTML"
| compare="PreferredRenderingMIME"
| >| argument="text/html" />
| >| </deviceFilters>
| >| </system.web>
| >|
| >| and I've added device specific elements to an aspx
| page:
| >|
| >| <mobile:Label runat="server" >
| >| <DeviceSpecific>
| >| <Choice Filter="IsPocketIE" Text="Running on
| Pocket
| >| IE" />
| >| <Choice Filter="IsHTML" Text="Running on other
| HTML
| >| device" />
| >| <Choice Text="Running on other device" />
| >| </DeviceSpecific>
| >| <mobile:Label>
| >|
| >| When I build and run I get the error:
| >|
| >| Can find neither a device capability named 'IsHTML32'
| nor
| >| a public non-static method on the page
| named 'IsHTML32'
| >| that returns a System.Boolean and takes
| >| System.Web.Mobile.MobileCapabilities and System.String
| as
| >| arguments.
| >|
| >| What am I missing?
| >|
| >| jMM
| >|
| >
| >.
| >
|
 
J

John Miller

Hi Lewis,

No, changing the case doesn't help. It looks to me like
the <deviceFilters> element in the web.config is not
being read.

jMM
 
E

Earl Beaman[MS]

Hi Guys,

I believe that this error is due to the fact that you have a filter named
the same thing as the compare attribute. Try using a different filter
name, such as supportsColor or hasColor or something similar.

This error is easily reproducible with similar types of filters. For
example, this one will produce the same error as well.

<filter name="PreferredRenderingMime" compare="PreferredRenderingMime"
argument="text/html" />

A better name for this is "isHTML", and that will not cause an error. But
the above will.

Also, these values are definitely being read out of the web.config.

Thanks,
Earl Beaman
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no
rights.
 
E

Earl Beaman[MS]

I did some more research on this issue, and the reason for the error is
that there is an implicit filter created for every device capability, such
as IsColor. When you add a new filter with that name, you basically end up
with name collisions.
To get around the issue, you do need to use filters with different names
then the capabilities already established.

Thanks,
Earl Beaman
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no
rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top