Device Filters

Discussion in 'ASP .Net Mobile' started by John Miller, Sep 10, 2003.

  1. John Miller

    John Miller Guest

    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
    John Miller, Sep 10, 2003
    #1
    1. Advertising

  2. 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" <>
    | Sender: "John Miller" <>
    | References: <0bed01c377bf$ab6ad4f0$>
    <>
    | Subject: RE: Device Filters
    | Date: Thu, 11 Sep 2003 10:50:13 -0700
    | Lines: 135
    | Message-ID: <093f01c3788d$26fc80f0$>
    | 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" <>
    | >| Sender: "John Miller" <>
    | >| Subject: Device Filters
    | >| Date: Wed, 10 Sep 2003 10:19:19 -0700
    | >| Lines: 44
    | >| Message-ID: <0bed01c377bf$ab6ad4f0$>
    | >| 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
    | >|
    | >
    | >.
    | >
    |
    Lewis Wang [MSFT], Sep 12, 2003
    #2
    1. Advertising

  3. John Miller

    John Miller Guest

    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

    >-----Original Message-----
    >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" <>
    >| Sender: "John Miller" <>
    >| References: <0bed01c377bf$ab6ad4f0$>
    ><>
    >| Subject: RE: Device Filters
    >| Date: Thu, 11 Sep 2003 10:50:13 -0700
    >| Lines: 135
    >| Message-ID: <093f01c3788d$26fc80f0$>
    >| 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" <>
    >| >| Sender: "John Miller" <>
    >| >| Subject: Device Filters
    >| >| Date: Wed, 10 Sep 2003 10:19:19 -0700
    >| >| Lines: 44
    >| >| Message-ID: <0bed01c377bf$ab6ad4f0$>
    >| >| 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
    >| >|
    >| >
    >| >.
    >| >
    >|
    >
    >.
    >
    John Miller, Sep 12, 2003
    #3
  4. 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.
    Earl Beaman[MS], Sep 17, 2003
    #4
  5. 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.
    Earl Beaman[MS], Sep 18, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nishadixit
    Replies:
    5
    Views:
    1,229
    Joe Discar
    Jun 1, 2005
  2. Dieter Vanderelst

    using the Filters DLL (image filters)

    Dieter Vanderelst, Feb 15, 2006, in forum: Python
    Replies:
    1
    Views:
    401
    Michele Petrazzo
    Feb 15, 2006
  3. Replies:
    1
    Views:
    408
    santosh
    Nov 27, 2006
  4. Victor J. Servin

    Hrlp with Mobile Device Filters

    Victor J. Servin, Dec 1, 2003, in forum: ASP .Net Mobile
    Replies:
    1
    Views:
    109
    C├ęsar A. Fong Espinola
    Dec 8, 2003
  5. Matt
    Replies:
    0
    Views:
    455
Loading...

Share This Page