Using system;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Web;
Using system. Web. Mobile;
Using system. Web. sessionstate;
Using system. Web. UI;
Using system. Web. UI. mobilecontrols;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Using system. Data. oledb;
Public partial class viewbook: system. Web. UI. mobilecontrols. mobilepage
{
Public int dxclass;
Public int curpage;
Protected void page_load (Object sender, eventargs E)
{
If (request. querystring ["menuid"]! = NULL)
{
Dxclass = int32.parse (request. querystring ["menuid"]. tostring ());
}
If (! This. ispostback)
{
This. BIND ();
}
}
// Obtain the Directory
Private dataset getmenuds (INT menuid)
{
Oledbconnection con = new oledbconnection (@ "provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("app_data/dx. mdb "));
Con. open ();
String strcmd = "select * From menu where from =" + menuid;
Oledbdataadapter da = new oledbdataadapter (strcmd, con );
Dataset DS = new dataset ();
Da. Fill (DS );
Con. Close ();
Return Ds;
}
// Data Binding
Private void BIND ()
{
This. list1.items. Clear ();
Dataset menuds = getmenuds (dxclass );
This. label3.text = convert. tostring (menuds. Tables [0]. Rows. Count/10 + 1 );
Curpage = int32.parse (this. label2.text); // the current page
// If the current page is the first page with only one page, no button is displayed.
If (this. label2.text = This. label3.text & this. label2.text = "1 ")
{
This. command1.visible = false;
This. command2.visible = false;
}
Else if (this. label2.text = "1") // if the current page is the first page, the previous page button is not displayed
{
This. command1.visible = false;
This. command2.visible = true;
}
Else if (this. label2.text = This. label3.text) // if the current page is the last page, the next page button is not displayed.
{
This. command1.visible = true;
This. command2.visible = false;
}
Else
{
This. command1.visible = true;
This. command2.visible = true;
}
If (convert. toint32 (this. label2.text) = convert. toint32 (this. label3.text ))
{
For (INT I = (curpage-1) * 10; I <menuds. Tables [0]. Rows. Count; I ++)
{
String dxshort = menuds. Tables [0]. Rows [I] ["menuname"]. tostring ();
Cancelistitem item = new cancelistitem (dxshort, "viewlist. aspx? Bookid = "+ menuds. Tables [0]. Rows [I] [" menuid "]. tostring ());
This. list1.items. Add (item );
}
}
Else
{
For (INT I = (curpage-1) * 10; I <curpage * 10-1; I ++)
{
String dxshort = menuds. Tables [0]. Rows [I] ["menuname"]. tostring ();
Cancelistitem item = new cancelistitem (dxshort, "viewlist. aspx? Bookid = "+ menuds. Tables [0]. Rows [I] [" menuid "]. tostring ());
This. list1.items. Add (item );
}
}
}
// Previous Page
Protected void command1_click (Object sender, eventargs E)
{
This. label2.text = convert. tostring (int32.parse (this. label2.text)-1 );
This. BIND ();
}
// Next page
Protected void command2_click (Object sender, eventargs E)
{
This. label2.text = convert. tostring (int32.parse (this. label2.text) + 1 );
This. BIND ();
}
}
1, format
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype HTML public "-// wapforum // dtd xhtml mobile 1.1 //" http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd ">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> document title </title>
</Head>
<Body>
</Body>
</Html>
Call
<A href = "wtai: // WP/MC; 13888888888"> call me now </a>
When accessing the ASP site, different content will be output based on the accessed device. If you access the site via IE, HTML will be output. If you access the site via mobile phone, WML will be output. What makes him so intelligent? The key is in the <browsercaps> section of the configuration file!
Add this in webconfig, which can force the output of WML, and other mobile setting attributes are in this.
<Browsercaps>
<Result type = "system. Web. Mobile. mobilecapabilities, system. Web. Mobile, version = 1.0.5000.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a"/>
<Use VaR = "http_user_agent"/>
Browser = unknown
Version = 0.0
Majorversion = 0
Minorversion = 0
Frames = false
Tables = false
Cookies = false
Backgroundsounds = false
VBScript = false
Javascript = false
Javaapplets = false
Activexcontrols = false
Win16 = false
Win32 = false
Beta = false
Ak = false
SK = false
AOL = false
Crawler = false
CDF = false
Gold = false
Authenticodeupdate = false
Tagwriter = system. Web. UI. html32textwriter
ECS mascriptversion = 0.0
Ms domversion = 0.0
W3cdomversion = 0.0
Platform = unknown
Css1 = false
Css2 = false
Xml = false
Mobiledevicemanufacturer = "unknown"
Mobiledevicemodel = "unknown"
Gatewayversion = "NONE"
Gatewaymajorversion = "0"
Gatewayminorversion = "0"
Preferredrenderingtype = "wml11"
Preferredrenderingmime = "text/vnd. WAP. WML"
Preferredimagemime = "image/vnd. WAP. wbmp"
Defaultscreencharacterswidth = "12"
Defaultscreencharactersheight = "6"
Defaultscreenpixelswidth = "96"
Defaultscreenpixelsheight = "72"
Defaultcharacterwidth = "8"
Defaultcharacterheight = "12"
Screenbitdepth = "1"
Iscolor = "false"
Inputtype = "telephonekeypad"
Numberofsoftkeys = "0"
Maximumsoftkeylabellength = "5"
Caninitiatevoicecall = "false"
Cansendmail = "true"
Hasbackbutton = "true"
Renderswmldoacceptsinline = "true"
Renderswmlselectsasmenucards = "true"
Rendersbreaksafterwmlanchor = "false"
Rendersbreaksafterwmlinput = "false"
Rendersbreakbeforewmlselectandinput = "true"
Requiresattributecolonsubstitution = "true"
Requiresphonenumbersasplaintext = "false"
Requiresurlencodedpostfieldvalues = "false"
Requiredlanguagnamevalue = ""
Rendersbreaksafterhtmllists = "true"
Requiresuniquehtmlcheckboxnames = "true"
Requiresuniquehtmlinputnames = "true"
Requiresuniquefilepathsuffix = "true"
Supportscss = "false"
Hidesrightalignedmultiselectscrollbars = "false"
Canrenderafterinputorselectelement = "true"
Canrenderinputandselectelementstogether = "true"
Canrenderoneventandprevelementstogether = "true"
Cancombineformsindeck = "true"
Canrendermixedselects = "true"
Canrenderpostbackcards = "true"
Canrendersetvarzerowithmultiselectionlist = "true"
Supportsimagesubmit = "true"
Supportsselectmultiple = "true"
Requireshtmladaptiveerrorreporting = "false"
Requirescontenttypemetatag = "false"
Requiresdbcscharacter = "false"
Requiresoutputoptimization = "false"
Supportsaccesskeyattribute = "false"
Supportsinputistyle = "false"
Supportsinputmode = "false"
Supportsimodesymbols = "false"
Supportsjphonesymbols = "false"
Supportsjphonemultimediaattributes = "false"
Maximumrenderedpagesize = "2000"
Requiresspecialviewstateencoding = "false"
Requiresnobreakinformatting = "false"
Requiresleadingpagebreak = "false"
Supportsquerystringinformaction = "true"
Supportscachecontrol1_ag = "true"
Supportsuncheck = "true"
Canrenderemptyselects = "true"
Supportsredirectwithcookie = "true"
Supportsemptystringincookievalue = "true"
Cachesallresponseswithexpires = "false"
Requiresnosoftkeylabels = "false"
Defaultsubmitbuttonlimit = "1"
Supportsbold = "false"
Supportsitalic = "false"
Supportsfontsize = "false"
Supportsfontname = "false"
Supportsfontcolor = "true"
Supportsbodycolor = "true"
Supportsdivalign = "true"
Supportsdivnowrap = "false"
Supportscharacterentityencoding = "true"
Ismobiledevice = "false"
</Browsercaps>
Set
Page. response. expires =-1;
Response. cachecontrol = "public ";
YesCancel the mobile device cache and passRedirecttomobilepage function for redirection.
In the last cell phone.