Rafael del Corr...'s profile..:: Blog de Rafael del ...BlogLists Tools Help

Blog


    HTML Controls vs. WMC

    Estamos acostumbrados quizá, a generar código para que luego se renderice basado en HTML, pero nos tenemos que acostumbrar a la idea que en ASP.NET MOBILE el código que se devuelve a un dispositivo luego de un request no está definido por el servidor, sino por el dispositivo.

    En ASP.NET se podía codificar un control HTML y que corriera en el servidor con el simple hecho de agregarle dentro de las propiedades "runat=server", lo cual permitía acceder a las propiedades, métodos y eventos del control, pudiendo modificar así, por ejemplo, la propiedad "Text" de un Label.

    En ASP.NET MOBILE, al no trabajar con un lenguaje de etiquetas fijo, no podemos anexar a nuestro código ningún control de tipo HTML o WML, sino que los únicos controles con los que podemos trabajar son los Web Mobile Controls (System.Web.UI.MobileControls).

    El siguiente es un ejempo de como crear y alterar las propiedades de un Mobile Control:

    <%

    @ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

    <%

    @ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>

    <

    html xmlns="http://www.w3.org/1999/xhtml" >

      <

    body>

        <

    mobile:Form id="Form1" runat="server">

          <

    mobile:Label ID="Label1"

            runat="server"

            Alignment

    ="Left"

            Font-Bold

    ="True"

            Visible

    ="True"

            Wrapping

    ="Wrap"

            Text

    ="El mundo de ASP.NET MOBILE..."

          />

        </mobile:Form>

      </body>

    </html>

    Este código tiene que funcionar perfectamente si uno lo copia en el "Markup View" en Visual Studio 2005. Hagan la prueba de colocar un control HTML, y van a comprobar que el motor de ASP.NET no lo procesa.

    En el Compact Framework 2.0, se han agregado un par de nuevo controles (no son muchos) y ahora se puede modificiar la propiedad "BackColor" en la mayoría de ellos. A continuación, dejo una tabla con el Mobile Web Control y su correspondiente en ASP estándar:

     

    ASP.NET
    (asp:Nombre_Control)
    ASP.NET MOBILE (mobile:Nombre_Control)
    AdRotator AdRotator
    BulletedList SelectionList
    Button Command
    Calendar Calendar
    CheckBox SelectionList
    CheckBoxList SelectionList
    RangeValidator RangeValidator
    CustomValidator CustomValidator
    DataList List
    DataGrid ObjectList
    - DeviceSpecific
    DropDownList SelectionList
    Hyperlink Link
    Image Image / DynamicImage
    ImageButton Command
    LinkButton Command
    Label Label
    ListBox SelectionList
    Panel Panel
    - Phone Call
    RadioButton SelectionList
    RadioButtonList SelectionList
    RangeValidator RangeValidator
    RegularExpressionValidator RegularExpressionValidator
    RequireExpressionValidator RequireExpressionValidator
    Repeater

    Repeater

    Table -
    TextBox TextBox
    - TextView
    ValidationSummary ValidationSummary

     

    Como pueden ver, hay casos en que los controles son los mismos, y basta con cambiar alguna o algunas propiedades para obtener un WMC que reemplace a un ASP Control (es el caso de un SelectionList o un Command). Por otra parte, también tenemos controles que no existen en ASP.NET (como ser PhoneCall, DeviceSpecific,TextView).

    Hay controles de ASP.NET 2.0 que no aparecen en la lista, pero que a medida que pueda subirlos junto con su respectivo WMC, lo ire haciendo porque quizá hay controles en ASP.NET que no tienen su correspondiente en ASP.NET MOBILE, pero que se pueden conseguir, como ya vimos que pasa con el SelectionList, tan solo cambiando algunas propiedades, asíque cuando tenga nuevas soluciones, las postearé.

    Hasta la próxima.

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://mobiledevp.spaces.live.com/blog/cns!B1F45CF18768D48A!115.trak
    Weblogs that reference this entry
    • None