Migrating from ASP to ASP + -- impatient? Convert other pages

Source: Internet
Author: User

Impatient? Switch to another page!
Author: yuchen


For the remaining pages, we use the ASP + DataList or Repeater controls to draw a gourd Based on the samples. This is necessary because the data layout needs to be customized according to the design requirements, rather than a standard table display. There is a page named classcatalog. aspx, which requires you to check the value and then run one of the two possible outputs based on the selected value. This page uses the Repeater control. Therefore, we create rows and columns in the table explicitly without allowing the control to do everything. This is done within templates. In ASP, it looks like this:

Check for discounts

If rsSessions ("Special") = True Then

If this course offers discounts, "Special Offer!" is displayed !"

Response. Write "<td valign = top align = center>" & vbCrLf

Response. Write "<a href =" "classdetail. asp? SessionID ="

Response. Write rsSessions ("SessionID ")

Response. Write "name =" "Click for more detail" ">"

Response. Write "Special Offer! "

Response. Write "</td>"

Else

If this course does not offer discounts, output "--" in the bar "--"

Response. Write "<td valign = top align = center> -- </td>"

End If

To achieve the same effect in ASP +, we use a function. In the script block, which is located under the Page_Load event, we create the following code:

Function CheckSpecial (ByRef blnSpecial As Boolean ,_

ByRef intNumber As Integer) As String

If blnSpecial = True Then

CheckSpecial = "<a href =" & Chr (34 )&_

"Classdetail. aspx? SessionID = "&_

IntNumber & Chr (34) & "> Special !! </A>"

Else

CheckSpecial = "--"

End If

End Function

Then, you only need to call the function from ASP + Repeater:

<Template name = "ItemTemplate">

<Tr>

[Other data being displayed]

<Td valign = top align = center>

<% = CheckSpecial (Container. DataItem ("Special "),

Container. DataItem ("Session_ID") %>

</Td>

</Tr>

</Template>

Container refers to the parent object that involves the data of our ASP + Reapter control. Call Container. DataItem ("Special") and Container. DataItem ("Session_ID") to pass the values of columns in the parent object (namely the ASP + Repeater control) to the function.


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.