Get your homepage to support a variety of browsing devices (asp.net) (Part One)

Source: Internet
Author: User
We've seen the introduction to mobile controls, and now we're going to look at his usage.

Using mobile control
Using mobile control is as easy as using other asp+ controls. In fact he is much simpler because he is producing an entire page, not part of the page. We even
Don't have to think about it. Xml....? > and <doctype .......> These tags, they will be added automatically.

We use Paner control to generate <card> and <deck>

<mobile:panel runat= "Server" id= "Pnlmain" >
<mobile:form runat= "Server" >
<mobile:label runat= "Server" >enter your name:</mobile:label>
<mobile:textbox runat= "Server" id= "Nameedit"/>
<mobile:command runat= "Server" id= "button" label= "OK"
Targettype= "Formaccept"/>
</Mobile:Form>
</Mobile:Panel>

Note: In previous versions, each page must have a mobile:form, and now it is not needed.

Here's what the above program sees on the normal browser:



However, if you use a WAP phone to watch, you will see the following results:



We'll add a welcome message to the page that contains the username, so we have to add another panel control to the deck.

<mobile:panel runat=server id= "Pnltwo" >
<mobile:form runat= "Server" >
<mobile:label runat= "Server" id= "Welcomemessage" type= "Title"/>
</Mobile:Form>
</Mobile:Panel>

We let the user press the OK key and then display this information. There are different ways to operate in WAP phones, meaning the same. So, we have to write a VB code to deal with
This event.

<script language= "VB" runat= "Server" >
Sub Button_onclick (Sender as Object, Args as EventArgs)
Welcomemessage.text = "Welcome '" & Nameedit.text & "'"
Setcurrentpanel (Pnltwo)
End Sub
</script>

The first card (or panel) contains a command control that specifies the event and the name of the ammonium button:

<mobile:command runat= "Server" id= "button" label= "OK"
Targettype= "Formaccept"/>

The code in the subroutine is primarily used to collect the user name from the TextBox control, and then the Labael in the second panel shows:

Welcomemessage.text = "Welcome '" & Nameedit.text & "'"

When that's all done, we're going to start each page

Setcurrentpanel (Pnltwo)





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.