ASP development of China Unicom CDMA
The following are the essays on WAP development. Some of them are not very helpful for beginners. You are welcome to come up with some tips. Learn and make progress together ^-^
1. Configure the WAP environment for IIS
Add a new file type in the Properties> HTTP header> mime ing of the WAP site, as shown in the following code:
Associated file name content type
WML text/vnd. WAP. WML
Wmlc application/vnd. WAP. wamlc
WMLS text/vnd. WAP. WMLScript
Wmlsc application/vnd. WAP. WMLScript
Wbmp image/vnd. WAP. wbmp
Compile a WML file or use ASP to compile a dynamic web page
If ASP is used for writing, add it at the beginning of the source code.
<% @ Language = "VBScript" codePage = "65001" %>
<% Response. contenttype = "text/vnd. WAP. WML; charset = UTF-8" %>
UTF-8 encoding
You can use the simulator to browse.
2. the WAP encoding is strict and the tags are case sensitive. The tag must match. Beginners often make such mistakes.
3. When it comes to tag matching, this problem is involved. When querying a record in a table, if no record is found in ASP, the system outputs "no record prompt" and responds. End. But not in WAP, because it does not output closed tags such as </card> </WML>.
The method I use is. After obtaining the record set
.
.
If Rs. EOF then
Wrong = "no records... "
Else
'Normally, the page is displayed .....
End if
Respong. Write wrong
.
</P>
</Card>
</WML>
This prevents the tag from being closed.
4. You must first download the image
A. correct image format: some mobile phones support PNG, while others support GIF, BMP, and jpg. (Most of China Unicom's CDMA systems support PNG)
B. The image path must be correct. For example, the absolute path is http: // *****/picdown/aa.png.
C. The image size should be appropriate: the size of the previewed image cannot exceed 10 KB, and the size of the image to be downloaded cannot exceed 30 kb. (I don't know if there are any standards. This is the data I got in the actual test.) download some pictures or ringtones supported by mobile phones may be larger than <50kb, but in order to take care of most mobile phones, <30kb is recommended.
D. The image size must correspond to the image name, that is, how big aa.png is and how big it is in size. The two correspond.
E. When some mobile phones store images in a certain number of mobile phones, similar prompts such as "too many downloads" will be displayed. Some mobile phones have previews --> Save (for example, Moto) some do not. After downloading, save it to your mobile phone (lg8180 ).
F. Determine whether the download is successful. You can obtain the status in the specified file. If status = 'OK' indicates that the download is successful. If yes, the download is successful and the number of downloads is + 1, otherwise, a message indicating download failure is displayed.
5. pagination in WAP
Pages are the same as those on the web, but some functions are simplified. Below are common pages. If you do not write a function, you can easily modify it.
Write the following code after opening the record set:
<%
Filepath = request. servervariables ("path_info") %>
<% Page = 1
Page = request ("page ")
Rs. pagesize = 8' number of records per page
If not isempty (TRIM (Request ("page") then
Page = CINT (Request ("page "))
If page> Rs. pagecount then
Rs. absolutepage = Rs. pagecount
Elseif page <= 0 then
Page = 1
Else
Rs. absolutepage = page
End if
End if
%>
Next, we want to display the page, which is usually written after the record set loop output is completed:
<% If Rs. pagecount <> 1 and Rs. pagecount <> 0 then %>
<Br/>
<% If page> Rs. pagecount then %>
<A Title = "OK" href = "<% = filepath %>? Page = <% = page-1%> "> previous page </a>
<% Else %>
<% If page <> 1 then %>
<A Title = "OK" href = "<% = filepath %>? Page = <% = page-1%> "> previous page </a> <br/>
<% End if %>
<A Title = "OK" href = "<% = filepath %>? Page = <% = page + 1%> "> next page </a>
<% End if %>
<% End if
Response. Write "no." & page & "Page total" & Rs. pagecount & "page"
%>
Note that the next page is displayed first, and then the previous page is displayed, which is not the same as that on the web.
In addition, if the content on this page is displayed as a parameter transmitted through the previous page, as a condition
<A Title = "OK" href = "<% = filepath %>? Page = <% = page + 1%> "> next page </a>
This parameter must be added to all locations. Otherwise, the parameter will be dropped during next page connection.
For example, the type of News selected from the previous page to display news. On the list. ASP page, write newtype = request. Form ("newtype") to obtain the selected news type.
Then SQL = "Select... where newtype = '" & newtype &"'". Complete the preparation of the record set. Note: you must write it on the next page.
<A Title = "OK" href = "<% = filepath %>? Page = <% = page-1%> & amp; newtype = <% = newtype %> "> previous page </a> <br/>,
In this form, the number of conditions is followed by the number of conditions.
However, this produces a problem. Writing newtype = request. Form ("newtype") in real time will not get the value of Newtype. Therefore, newtype = request ("newtype") should be written at the beginning of the header "). You can bring the parameter to the connection on the next page.
The previous and next problems in WAP.
During development, news, jokes, downloads, and other services provide convenience for users. After a record is completed, the next record operation is provided, the following is a brief description of the implementation method of the next record.
For example, the display of news is a record of international news, list. ASP is used for display. The SQL statement select * From newsinfo where type = 'internet' is used to obtain a set of qualified records. During browsing, the ID of the current record is 10, the ID of the next record is idnext = 10 + 1 = 11, the ID of the previous record is idpre = 10-1 = 9, and then <a href = "list. asp? Id = '"& idnext &"' "> previous </a>. This method is lacking. It is applicable only to consecutive IDs, that is to say, the IDs of all international news are continuous. If international news and domestic news are written in the table, your ID-1 may be Chinese news, the condition type = 'internet' does not work.
The correct and concise approach should be like this (maybe there are better practices ):
The current ID is idnow, And the newsinfo table is auto-incremented by ID.
Obtain idnext = select top 1 from newsinfo where type = 'internet' and ID> '"& idnow &"'
Obtain idpre = select top 1 from newsinfo where type = 'internet' and ID <'"& idnow &" 'order by ID DESC
You don't need to worry about the remaining issues. Note that the next item is displayed first, and then the previous one is displayed, so that users can conveniently access the problem.
Mixing news and other pictures and text in WAP
During WAP development, the image and text are mixed and can adopt UBB encoding. The principle is to define a special format and use the mid and replace functions for conversion. For example, defining [img] [/img] indicates the start and end of an image.
However, note the difference between web and WAP. Replace string1all = Replace (string1all, "[img]", "</P> <p align =" "center"> String1all = Replace (string1all, "[/img]", "" alt = "/> </P> <p> ")
The image is displayed in the center.
Paging of news Novels
Too Long News and novels in WAP will bring great inconvenience to everyone. Therefore, paging is required. For example, 300 words are displayed on each page.
Pagewordnum = 300 'the number of words displayed per page. Here, 300 can be a variable.
Startword = 1
Length = Len (content) 'total length of the content to be displayed
Pageall = (Length + PageWordNum-1)/pagewordnum total number of pages that the news article can be divided
I = request. querystring ("I ")'
If isnull (I) or I = "" then', if it is the first news, the default is I = 0.
I = 0
End if
Content = mid (content, startword + I * pagewordnum, pagewordnum) 'uses the mid function to intercept news content (meaning of the MID function: return a specified number of characters from the string)
.
.
.
<%
'Start paging
If 0 <= I <pageall then
If CINT (I) <CINT (pageall)-1 then %>
<A href = "listfengshuiinfo. asp? I = <% = I + 1%> "> next page </a> <br/>
<% End if
If CINT (I)> 0 then %>
<A href = "listfengshuiinfo. asp? I = <% = I-1 %> "> previous </a> <br/>
<% End if
End if
%>
End.
Note: 1. <a href = "listfengshuiinfo. asp? I = <% = I + 1%> "> listfengshuiinfo. asp? I = <% = I + 1%> you can add variables according to your actual environment requirements.
2. Description of the MID function:
Returns a specified number of characters from a string.
Mid (string, start [, length])
Parameters
String
String expression, which returns characters. If string contains null, return null.
Start
The start position of the extracted characters in string. If start exceeds the number of characters in the string, Mid Returns a zero-length string ("").
Length
The number of characters to return. If the number of characters in the text is omitted or the length exceeds (including the characters at START), all characters from start to end of the string are returned.