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

Blog


    Text Controls

    We have three  type of “Text Controls” inside the WMC´s:  the LiteralText, Label and TextView control. Each one, has their functionalities. Some of them admit HTML labels, some can alternate their behaviors through server code, etc. This is what we are going to see in this article, in order according to their functionalities:

    First of all we have the LiteralText. Though  is not a WMC, it is a class that inherits from MobileControl and represent all kind of text that we want to make visible to the user and we do not want to control from the server. This text allows to use some labels similar to HTML ones. For example, we can use:

    -          Paragraph labels (<p></p>)

    -          Font style labels (black and italic) (<b></b> and <i></i>)

    -          Line feed labels (<br> or </br>)

    -          Link labels (<a href=”url”></a>)

    This labels will be processed according to the language that the device that make the request supports. And here we have an example of a literal text using all the supported labels:

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <body>
       <
    mobile:Form id="Form1" runat="server">
         
    <p>
            
    This a <b>test</b> to see that a <i>simple</i> text <br></br>
             could be reached using similar <a href="http://www.msn.com">HTML</a>
          </p>

       </mobile:Form>
    </body>
    </html>

    The ASP.NET engine will render the page code according to the  device that make the request (HTML, WML, etc.).

    In second place: the Label control. This is a WMC and it behavior could be modified from the server code side. This control, apart from the common properties has a new one: “Text”. This property allows us to change the text value of the label,  and could be modified in any time. In this type of controls you are not able to use HTML labels as in the case of the LiteralText control. There are two possibles sintax to set the text value of a label:

    a)      Between the labels

       <mobile:Form id="Form1" runat="server">
          <mobile:Label ID="Label1" Runat="server">
             We are setting the text property value between the labels.
          </mobile:Label>
       </
    mobile:Form>

    b)      Modifying the Text property

       <mobile:Form id="Form1" runat="server">    
          <mobile:Label ID="Label2" Runat="server"
             Text="We are setting the text    through the Text property">
          </mobile:Label>        
       </mobile:Form>

    Something to bear in mind is that a label can not be paginated. This is not the same for  our third text control: the TextView.

    This controls has the common properties and it is added Text, that satisfies the same necessity that the case of a Label control. But if you are wondering what is the difference between the Labels and the TextView, the answer is that this control allows to, for example, bind data with a database. We should use this control, for all those texts that, storing it in a database requires a Memo or Text field type.

    In this control, we can use the same HTML labels that we can use in the LiteralText, added to all the rest of the HTML labels (always respecting the type of labels permitted according with what we see in the second post of this blog). Apart from the modifications that this labels permit, we are able to use the common properties as any control (Font.Bold, Font.Italic, etc.)

    An other very important feature of this control, as we said, is that it could be “paginated”. This is very useful in the case that we are navigating with a low memory capacity device and the text is too long for it to support it. In this case, we must “turn on” the property that allows the pagination (Paginate=”True”)

    Here we have an example:

    <mobile:Form id="Form1" runat="server">    
       <
    mobile:TextView ID="TV1" Runat="server">
          This is a <b>looooong</b> text, that it could be paginated, wrapped, bolded or what ever we
          want to do according to the common and owned properties.
    <br />
    Excelent... is not it?
       </
    mobile:TextView>
    </mobile:Form>

    Well, that´s it all for now. We are seeing in the next post with those controls that allows as to go and came back to the server, to another page, etc.: Image, Link and Command, their common properties, their owned properties and events, and how, mixing these we can get more functionalities.

    See you!!

    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!122.trak
    Weblogs that reference this entry
    • None