A full-featured column management program-> This is the second application of ASP.net (ii)

Source: Internet
Author: User
Tags definition integer
A full-featured column management program-> This is the second application of ASP.net (ii)
/*
Tofu production, are fine
Http://www.asp888.net Tofu Technology Station
If reproduced, please retain the full copyright information
*/
In our last article, we quoted a function package file func.aspx, in this article, we explain in detail, this func.aspx file
<%@ Assembly name= "System.Net"%>
<%@ Import namespace= "System.Net"%>
<%@ Import namespace= "System.IO"%>
<%@ Import namespace= "System.Data"%>
<%@ Import namespace= "System.Data.SQL"%>
' These import I will not say, in front of the article sp+ commonly used in namespace's explanation has already involved
<script language= "VB" runat=server>
function Replacesql (str1 as String) as String
' The use of SQL statements in ASP.net also shows the issue of ' ', so use the Replace function to convert ' ' ' to ' '
Replacesql=replace (str1, "'", "" ")
End Function
function Getconn () as SqlConnection
' We're here to unify the code that connects the database to the management
Dim Conn as SqlConnection
Dim CFG as HashTable
CFG = Context.getconfig ("appsettings")
Conn = New SqlConnection (cfg ("Conn"))
Getconn=conn
End Function

Sub Writepage (start as integer,file as string,intlen as integer,intpagecount as integer,intreccount as Integer)
' This is a portable paging program
' Page-handling
Dim strwrite As String
Strwrite= "<table border=1 width=100%><tr><td>"
Response.Write (Strwrite)

If Start=0 Then
Strwrite= "Home"
Else
Strwrite= "<a href=" "& File &"? start=0 ' > Home </a> '
End If
Response.Write (Strwrite)

If Start>=1 Then
Strwrite= "<a href=" "& File &"? start= "& CStr (Start-intlen) &" "> Page </a>"
Else
strwrite= "on page"
End If
Response.Write (Strwrite)

If Start+intlen<intreccount Then
' Not yet to the last page of data
Strwrite= "<a href=" "& File &"? start= "& CStr (Start+intlen) &" "> Next page </a>"
Else
strwrite= "Next Page"
End If
Response.Write (Strwrite)

If Start+intlen<intreccount Then
' Not yet to the last page of data
strwrite= "<a href= '" & File & "? start=" & CStr ((intPageCount-1) *intlen) & "' > Last </a>"
Else
Strwrite= "Last"
End If
Response.Write (Strwrite & "</td><td>")

Strwrite= "Current total articles" & CStr (Intreccount) & "chapter, now is <font color=red>" & CStr ((Start/intlen) +1) & "/" & Amp CStr (Intpagecount) & "</font> page"
Response.Write (Strwrite)
Strwrite= "</td></tr></table>"
Response.Write (Strwrite)
End Sub
</script>
We must note in the asp.net that when we define a function in asp.net, we must pay attention to the <script runat=server. > in the definition of functions, and not as an ASP between <% and%> definition, the advantage is that the definition of the function is simple and clear, the readability of the program has improved a lot, but there is a very inconvenient place is in the <script> Can not be as convenient as in <%%> nested call HTML code, but must use Response.Write (ss), this is an inconvenient place


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.