C # Development WAP Program

Source: Internet
Author: User
Tags prev tostring
The program usually work and so on girlfriend always have to wait a long time, want to read and have no belt, only play mobile phone games, GPRS internet, as if a lot of content is to pay, just download ringtones, what pictures, boring! It is best to use mobile phone to read novels, the network is not like a free WAP novel, the Office of the younger sister also want to use mobile phone to read novels, it seems that only their own to do one.
All say Java is the development of WAP, but WAP need this "code" to go to that "code", really trouble, forget, see if you can do a WAP station with C #.
It's easy to come by, WAP is using UTF8 code, as if there is any WML and so on, WML search data on the Internet, and XML is similar to the usual use of XML is quite a lot, WML is simple, C # directly can be set response coding, it seems to have a chance, first write a " Hello Wife "Bar,
Set ContentType type
Response.contenttype= "TEXT/VND.WAP.WML";
Set encoding
Response.contentencoding=system.text.encoding.utf8;
The following is part of the content written under the WML protocol
wapcontent= "<?xml version=\" 1.0\ "encoding=\" utf8\ ">\r\n";
wapcontent+= "<! DOCTYPE WML public \ "-//wapforum//dtd WML 1.1//en\" \ "http://www.wapforum.org/dtd/wml_1.1.xml\" ><wml>\r\n ";
wapcontent+= "\ r \ n";
wapcontent+= "<card id=\" hello\ ">\r\n";
wapcontent+= "<p>hello wife </p>\r\n";
wapcontent+= "</card>\r\n";
wapcontent+= "\ r \ n";
wapcontent+= "</wml>\r\n";
wapcontent+= "\ r \ n";
Response.Write (wapcontent);
Try it with your cell phone, OK.
Now write a novel WAP program.
First from the online next novel, the existence of a directory, 1.txt
But the novel is too big, must first have a table of contents, press 2K paging bar, good boy, there are 200 pages, forget, to a direct selection of the Go bar:
wapcontent+= "<input name=\ pagenum\" size=\ "3\" maxlength=\ "10\" type=\ "text\" format=\ "*N\" emptyok=\ "true\"/ > ";
wapcontent+= "<anchor title=\" login\ ">\n";
wapcontent+= "<go href=\" wap.aspx\ "method=\" get\ ">\n";
wapcontent+= "<postfield name=\" page\ "value=\" $PAGENUM \ "/>\n";
wapcontent+= "</go> See this page!<br/>\n";
wapcontent+= "</anchor>\n";
All the code:
private void Page_Load (object sender, System.EventArgs e)
{
String wapcontent;
String MC;
Using the GB2312 simulator when debugging
Response.contenttype= "TEXT/VND.WAP.WML";
Response.contenttype= "Text/vnd.wap.wml;charset=utf-8";
response.contentencoding=system.text.encoding.utf8;//Unicode;//"UTF8";
Response.contentencoding=system.text.encoding.getencoding ("GB2312");
int n=0;
if (request["Page"]==null)
{
Show Table of Contents
wapcontent= "<?xml version=\" 1.0\ "encoding=\" utf8\ ">\r\n";
wapcontent= "<?xml version=\" 1.0\ "encoding=\" gb2312\ ">\r\n";
wapcontent+= "<! DOCTYPE WML public \ "-//wapforum//dtd WML 1.1//en\" \ "http://www.wapforum.org/dtd/wml_1.1.xml\" ><wml>\r\n ";

wapcontent+= "\ r \ n";
System.IO.FileInfo ofm=new System.IO.FileInfo (Request.PhysicalPath);
System.IO.StreamReader oreaderd=new System.IO.StreamReader (ofm.directoryname + "\" + "1.txt") System.Text.Encoding.Default);
Read 3000 words at a time

Mc=oreaderd.readtoend ();
Oreaderd.close ();
wapcontent+= "<card id=\" lists "+n.tostring () +" ">\r\n";

int k=mc.length/3000;
wapcontent+= "<p> catalogue </p>\r\n";
wapcontent+= "<p> total:" +k.tostring () + "page </p>\r\n";

wapcontent+= "<input name=\" sid\ "size=\" 3\ "maxlength=\" 10\ "type=\" text\ "format=\" *n\ "emptyok=\" true\ "/>";
wapcontent+= "<anchor title=\" login\ ">\n";
wapcontent+= "<go href=\" wap.aspx\ "method=\" get\ ">\n";
wapcontent+= "<postfield name=\" page\ "value=\" $SID \ "/>\n";
wapcontent+= "</go> See this page!<br/>\n";
wapcontent+= "</anchor>\n";

wapcontent+= "<onevent type=\" onenterbackward\ ">\r\n";
wapcontent+= "<prev/>\r\n";
wapcontent+= "</onevent>\r\n";



wapcontent+= "</card>\r\n";



wapcontent+= "\ r \ n";



wapcontent+= "</wml>\r\n";
wapcontent+= "\ r \ n";
Response.Write (wapcontent);
Return

}
Else
N=system.convert.toint32 (request["Page"));


wapcontent= "<?xml version=\" 1.0\ ">\r\n";
wapcontent+= "<! DOCTYPE WML public \ "-//wapforum//dtd WML 1.1//en\" \ "http://www.wapforum.org/dtd/wml_1.1.xml\" ><wml>\r\n ";

wapcontent+= "\ r \ n";
System.IO.FileInfo of=new System.IO.FileInfo (Request.PhysicalPath);
System.IO.StreamReader oreader=new System.IO.StreamReader (of.directoryname + "\" + "1.txt") System.Text.Encoding.Default);
Read 3000 words per hearing

Mc=oreader.readtoend ();
Oreader.close ();
if (mc.length>4000)
{
Mc=mc.substring ((n) *3000,3000);
Mc=mc.replace ("\ r \ n", "<BR/>");
Artmore=true;
}

3000 words per screen


wapcontent+= "<card id=\" lists "+n.tostring () +" ">\r\n";

wapcontent+= "<do type=\" accept\ "label=\" "+ (n-1). ToString () + "\ >\r\n";
wapcontent+= "<go href=\" wap.aspx? Page= "+ (n-1). ToString () + "\/>\r\n";
wapcontent+= "</do>\r\n";
wapcontent+= "<onevent type=\" onenterbackward\ ">\r\n";
wapcontent+= "<prev/>\r\n";
wapcontent+= "</onevent>\r\n";

wapcontent+= "<p>\r\n";
Wapcontent+=n.tostring () + "P";

WAPCONTENT+=MC;


wapcontent+= "</p>\r\n";

wapcontent+= "<do type=\" accept\ "label=\" next page \ ">\r\n";
wapcontent+= "<go href=\" wap.aspx? Page= "+ (n+1). ToString () + "\/>\r\n";
wapcontent+= "</do>\n";
Select Page
wapcontent+= "<input name=\" sid\ "size=\" 3\ "maxlength=\" 10\ "type=\" text\ "format=\" *n\ "emptyok=\" true\ "/>";
wapcontent+= "<anchor title=\" login\ ">\n";
wapcontent+= "<go href=\" wap.aspx\ "method=\" get\ ">\n";
wapcontent+= "<postfield name=\" page\ "value=\" $SID \ "/>\n";
wapcontent+= "</go> See this page!<br/>\n";
wapcontent+= "</anchor>\n";
wapcontent+= "</card>\r\n";



wapcontent+= "\ r \ n";



wapcontent+= "</wml>\r\n";
wapcontent+= "\ r \ n";
Response.Write (wapcontent);




}
Pick up the phone, www.tjkx.com/wap.aspx, try it, cool!!!
Use the phone to debug too much trouble, download a Winwap Pro3.1 in here to debug.
The tools are ready, it seems that C # is very good, write a small program is so simple




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.