ASP 后台写html生成前台table

来源:互联网 发布:扑克变牌衣淘宝女装 编辑:程序博客网 时间:2024/05/13 17:26

后台VB:

 If Not newTable Is Nothing And newTable.Rows.Count > 0 Then
            Dim str As StringBuilder = New StringBuilder()
            str.Append("<table border='1' cellpadding='0' cellspacing='0' class='tbl' style ='text-align :center '>")
            For i = 0 To newTable.Rows.Count - 1
                If i Mod 3 = 0 Then
                    str.Append("<tr>")
                End If
                Dim path As String = newTable.Rows(i)(2).ToString.Replace("~", "..")
                str.Append("<td>")
                str.Append("<table border='0' cellpadding='0' cellspacing='0' width='220' class='tbl' style ='text-align :center '>")
                str.Append("<tr>")
                str.Append("<td style='height :80px; text-align :center '>")
                str.Append("<input  type ='image' src ='..\image\czuft.jpg'  onclick ='' style ='height:56px;width :112px'/>")
                str.Append("</td>")
                str.Append("</tr>")
                str.Append("<tr>")
                str.Append("<td style='height :140px; text-align :center;'>")
                str.Append("<input  type ='image'  src ='" & path & "'  onclick ='' style =' height:112px;width :80px' />")
                str.Append("</td>")
                str.Append("</tr>")
                str.Append("<tr>")
                str.Append("<td style ='height :30px;font-weight :bold'>" & newTable.Rows(i)(1).ToString() & "</td>")
                str.Append("</tr>")
                str.Append("<tr>")
                str.Append("<td style ='height :30px;font-weight :bold'>" & newTable.Rows(i)(3).ToString() & "</td>")
                str.Append("</tr>")
                str.Append("<tr>")
                str.Append("<td style='height :40px; text-align :right; padding-right :10px;font-weight:bold'>NO." & newTable.Rows(i)(0).ToString() & "</td>")
                str.Append("</tr>")
                str.Append("</table>")
                str.Append("</td>")
                If i Mod 3 = 2 Then
                    str.Append("</tr>")
                ElseIf i = newTable.Rows.Count - 1 Then
                    str.Append("</tr>")
                End If            Next
            str.Append("</table>")
            Me.Literal1.Text = str.ToString()
        Else

        End If

 

前台aspx:

<div runat ="server" id ="divIamge" style ="width :660px;text-align:center; padding-top:20px; padding-left :300px ">
      <asp:Literal ID="Literal1" runat ="server" Text ="XXXX" ></asp:Literal>
         </div>