Embed WML tags in ASP. NET

Source: Internet
Author: User

Yesterday, we solved this problem about mobile control.
Using ASP. NET to develop WAP programs is convenient and easy to use with mobile control. However, if you want to use some elements of WML, you may not want to write the adapter very hard. For example, if you want to add a WML Prev element to the page, you can write it as <anchor Title = "back"> back <Prev/> </anchor>
But how to add it in a mobile form? I tried the following methods:
1. directly use response. In the page_load file of mobilewebform, enter
String AA = "<card id = \" card1 \ "Title = \" title \ "> ";
AA + = "<p> ";
AA + = "<anchor Title = \" back \ "> return <Prev/> </anchor> ";
AA + = "</P> ";
Response. Write (AA );
Of course, some device compatibility work should be added, which is omitted here.
The problem with this is that the written content must be at the top of the page.
2. Use application_endrequest
To put the content to the end, add the content after the response content render, but directly put the above Code into this event, but it cannot be displayed in openwave, it may be because openwave thinks this card is already behind the ending sign, so it does this.
Write in page_load
String AA = "<card id = \" card1 \ "Title = \" title \ "> ";
Response. Write (AA );
Then write in endrequest
If (this. Request. filepath. indexof ("yourmobileform. aspx ")! =-1)
{
String AA + = "<p> ";
AA + = "<anchor Title = \" back \ "> return <Prev/> </anchor> ";
AA + = "</P> ";
Response. Write (AA );
}
I lied to openwave.
3. Use the devicespecific control.
This method is an orthodox solution. Drag a devicespecific control on the form and design it
<Mobile: devicespecific id = "devicespecific2" runat = "server">
<Choice filter = "iswml11">
<Footertemplate>
<P>
<Anchor Title = "back"> return <Prev/> </anchor>
</P>
</Footertemplate>
</Choice>
</Mobile: devicespecific>
It may be because I don't use openwave very much. openwave ignores the above. Later, I added a device filter to determine that ismobiledevice is true. In this way, you can.
Put <footertemplate> at the end and 4. Write your own Adapter. In this case, I tried htmladapter. It's okay, but I wrote a WML adapter, and openwave won't, I don't quite understand what type openwave actually receives.

In addition, we will put all the content above at the beginning or end. What should we do if it is in the middle.
You can put a panel on the form, put the devicespecific in the panel, and then put the WML content in <contenttemplate>.
<P> <anchor Title = "DDD"> 3eee <Prev/> </anchor> </P>
You can put the things you want to put in the back.
For example, <Mobile: Label id = "label1" runat = "server"> label </Mobile: Label>
However, this label cannot be accessed by code, so you need to manually add the event
<Mobile: Label id = "label1" runat = "server" onLoad = "settext"> label </Mobile: Label>
Then add the function implementation to. CS.
Public void settext (Object sender, system. eventargs E)
{
(Sender as system. Web. UI. mobilecontrols. Label). Text = "dkkd ";
}

Continue Update (2004.9.9)
To put them in the middle, we don't have to use devicespecific. We can use custom controls to implement them. For example, we can derive one from the label and then reload onrender.
Protected override void onrender (system. Web. UI. htmltextwriter writer)
{
If (this. mobilepage. device. preferredrenderingtype = "XHTML-MP" |
This. mobilepage. device. preferredrenderingtype = "wml11 ")
{
Writer. writebegintag ("anchor ");
Writer. Write ("Title = \" "+ this. Title +" \ ">" + this. Text );
Writer. writebegintag ("Prev ");
Writer. writeendtag ("Prev ");
Writer. writeendtag ("anchor ");}
Else
Base. onrender (writer );
}
Then drag the control to form to implement it.

Related Article

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.