Developing the essay in WAP

Source: Internet
Author: User
Tags add format end sql prev return string

ASP Development Unicom CDMA

The following is in the development of WAP in the essay, some of them for the "veteran", it is not what, I hope to help beginners, we have any tips, welcome to the top. Common learning and common progress ^ ^
1,IIS configures a WAP environment
Add a new file type to the-->http header-->mime mapping as a WAP site, as follows:
Association 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
Write a WML file or write a Dynamic Web page using ASP
If you use ASP to write, in the beginning of the source code to add
<% @LANGUAGE = "VBSCRIPT" codepage= "65001"%>
<%response.contenttype = "TEXT/VND.WAP.WML; Charset=utf-8 "%>
Coding using Utf-8
You can use the emulator for browsing.
2,The code in WAP is more rigorous and the label is case-sensitive. Label must correspond. Beginners often make such mistakes.
3,When it comes to labeling, this is a problem. When querying a record in a table, the output "no record hint" and Response.End is not recorded in the ASP. But not in WAP, because this will not output </card></wml> and other closed tags.
The way I used to be. After you get the recordset



If Rs.eof Then
wrong= "No record at the moment ... "
Else
' Normal page display ...
End If
Respong.write wrong

</p>
</card>
</wml>
This prevents the label from being closed.
4,Image download must be done first
A, picture format to be correct: some mobile phone support PNG some support GIF, BMP, JPG. (Most of Unicom CDMA support PNG)
b, the picture path to be correct: absolute path such as Http://****/picdown/aa.png
C, the size of the picture should be appropriate: The preview of the picture can not exceed 10kb, for downloading pictures can not exceed 30kb. (This I do not know there is no standard, this is my actual test data), download some phone support pictures or ringtones may also be a big <50kb, but in order to take care of most mobile phones, so recommend <30kb.
D, the size of the picture must correspond to the name of the picture, that is, aa.png is how large, in its size to write how large, the two are corresponding.
E, some mobile phone in the phone to store a certain number of pictures, you will be prompted "too many downloads" and other similar tips, and some mobile phone has a preview--> save (such as: MOTO) Some did not, download the direct save to the phone (LG8180).
F, to determine the success of the user download, you can obtain status,if in the specified file status= ' OK ' to indicate that the download was successful, to the prompt download success, download times +1 and so on, otherwise, prompted download failed.
5,Paging in WAP
Pagination and the web is the same, but some features are simpler, the following is commonly used pagination, not written as a function is convenient for everyone to modify.

after opening the recordset, write the following code:

<%
Filepath=request.servervariables ("Path_info")%>
<%page=1
Page=request ("page")
Rs. PageSize = 8 ' number of records per page
If not IsEmpty ("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
%>

Then you want to display the paging, usually after the recordset loop output is finished:

<%if rs.pagecount<>1 and rs.pagecount<>0 then%>
<br/>
<%if Page>rs.pagecount Then%>
<a title= "Determine href=" <%=FILEPATH%>? page=<% =page-1%> "> Prev </a>
<%else%>
<%if page<>1 then%>
<a title=" OK " Href= "<%=FILEPATH%>? page=<% =page-1%> "> Prev </a><br/>
<% End If%>
<a title=" Determine href= <%=filepath% "?" page=<% = page + 1%> "> next </a>
<%end if%>
<%end if
Response. Write "" &page& "page Total" &rs.pagecount& "page"
%>

Note that the next page is displayed first, and then the previous page is displayed. This is not the same as the habits on the web.

In addition, if the content of the page is displayed as a parameter through the page transfer, the condition is similar
<a title= "Determine" href= "<%=FILEPATH%>? page=<% = page + 1%> "> Next </a>
, otherwise the parameters will be discarded when the next page is connected.
For example: The type of news that the user selects from the previous page to display the news. The List.asp page is written first, and Newtype=request.form ("NewType") gets the type of news the user chooses.
Then sql= "Select ... where newtype= '" "&NewType&" ". Completes the preparation of the collection of records. Note: When you proceed to the next page, write
<a title= "Determine" href= "<%=FILEPATH%>? page=<% =page-1%>&newtype=<%=newtype%> "> Prev </a><br/>
In this form, there are many conditions behind the condition.
But this creates a problem, and the instant newtype=request.form ("NewType") does not get the NewType value. So at the beginning of the page should be written newtype=request ("NewType"). Can be implemented to bring the parameters to the next page of the connection.

The previous and next question in WAP.

In the development, news, jokes, downloads and other services to provide users with the basic needs of a record after the completion of the next record to provide the operation, the following is a brief description of the next record implementation method.

For example, the display of news is the record of international news, list.asp to show, through the SQL statement SELECT * from Newsinfo where type= ' international ', to get a qualifying recordset, the user in the browsing process, the current record of id=10, The ID of the next record is idnext=10+1=11, the ID of the previous record is idpre=10-1=9, then <a href= "list.asp?id= '" &IdNext& "" "> The previous </a> This approach is deficient, only apply and ID is continuous, that is, all international news ID is continuous, if the international news and domestic news in the table is interspersed, then your id-1 is probably domestic news, conditionality type= ' international ' will not work.

The right and concise approach should be this (and perhaps there are better practices):

The current ID is idnow, and the table newsinfo is increased by ID.
Get Idnext=select top 1 from Newsinfo where type= ' international ' and id> ' &IdNow& '
Get Idpre=select top 1 from Newsinfo where type= ' international ' and id< ' &IdNow& ' ORDER by id DESC

The rest of the problem, needless to say, note, first display the next, and then display the previous one, so that users can be convenient.

WAP in the news and other pictures and text mixed row

In the WAP development, the picture and the text mix row, may adopt the UBB code, the principle is oneself definition altogether special format, uses the mid and the Replace function to carry on the transformation. For example, define [Img][/img], which indicates the beginning and end of the picture.
But be aware of the distinction between Web and WAP. Make the following substitution String1all = replace (string1all, String1all = replace (String1all, "/>", "" alt= "" "")/></p><p > ")

Will make the picture appear centered.

Pagination of a news novel

In the WAP long news and the novel, will bring the very big inconvenient to everybody. So the requirement for pagination display, such as 300 words per page to give examples.

Pagewordnum=300 ' The number of words displayed per page, where 300 can be a variable
Startword = 1
Length=len (content) ' to show the total length of the contents
Pageall= (length+pagewordnum-1) \pagewordnum ' The total number of pages to be divided by this piece of news

I=request. QueryString ("I") ' The mark of the first few pages
If IsNull (i) or i= "" then "if the news is just the beginning of the default i=0
I=0
End If
Content = Mid (Content,startword+i*pagewordnum,pagewordnum) ' intercepts the news content with the mid function (meaning of the mid function: returning a specified number of characters from a string)




<%
' Start paging operations
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%>" > Prev </a><br/>
<%end if
End If
%>

End.

Note:1, <a href= "listfengshuiinfo.asp?i=<%=i+1%>" > next page </a><br/> Listfengshuiinfo.asp?i=<%=i+1%> can add variables according to your actual environment needs.
2, the Mid function explains the explanation:
Returns a specified number of characters from a string.
Mid (String, start[, length])
Parameters
String
A string expression from which to return a character. If string contains null, NULL is returned.
Start
The start position of the extracted character part in string. If start exceeds the number of characters in string, Mid returns a 0 length string ("").
Length
The number of characters to return. If omitted or length exceeds the number of characters in the text, including the character at start, all characters in the string ending from start to string are returned.



Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.