asp subs to asp.net

Last post 05-19-2009 1:15 AM by Vishal. 1 replies.

Sort Posts:

  • asp subs to asp.net

    05-18-2009, 10:36 PM
    • Member
      point Member
    • thinking2
    • Member since 02-17-2009, 5:50 AM
    • Thousand Oaks CA
    • Posts 1

    I am new to .net but am familiar with classic asp. I do not understand how to use the asp:image component within a sub like I would have done in classic asp.

    In Classic asp I would use a sub for demonstration purposes
    <%
    Sub openShadow()
    %>
    <table cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td><img src="<%=getImgRoot() %>shadow_top_left.jpg" border="0" /></td>
    <td ><img src="<%=getImgRoot() %>shadow_top_mid.jpg" border="0" /></td>
    <td><img src="<%=getImgRoot() %>shadow_top_left.jpg" border="0" /></td>
    </tr>
    </table>
    <%
    End Sub

    call openShadow()
    %>

    I do not know how to do the above in .Net as a Sub so I made a Function but can not use the asp:img because it sees it as a string of text. Also I really want to double up on all my quotes.

    ########  BEGIN .NET SAMPLE

    Public Shared Function openShadow(ByVal xWidth As Integer) As String
    Dim str As String
    str = "<table width=""" & xWidth & """ cellpadding=""0"" cellspacing=""0"" border=""0"">" & _
    "<tr>" & _
    "<td><asp:Image ImageUrl="~/images/shadow_top_left.jpg" width="9" Height="9" GenerateEmptyAlternateText="true"  runat="server" /></td>" & _
    "<td><asp:Image ImageUrl="~/images/shadow_top_middle.jpg" width="9" Height="9" GenerateEmptyAlternateText="true"  runat="server" /></td>" & _
    "<td<asp:Image ImageUrl="~/images/shadow_top_right.jpg" width="9" Height="9" GenerateEmptyAlternateText="true"  runat="server" /></td>" & _
    "</tr>" & _
    "</table>"
    Return str
    str = Nothing
    End Function

    <%=openShadow("1002") %>

    ########  END .NET SAMPLE

    What am I missing? In classic asp I prefer Sub Procedures over a ton of include files. Can I do the same as I did in Calssic ASP but within .Net? Should I do it this way or is there a better way?

    Filed under: , ,
  • Re: asp subs to asp.net

    05-19-2009, 1:15 AM
    • Member
      703 point Member
    • Vishal
    • Member since 03-30-2005, 12:24 PM
    • Mumbai
    • Posts 141

    Have you tried using a Literal control? You can put any HTML into it and thus you will not have to use the asp:img control?

    Let me know if I've understood your problem correctly.

    Please take time to click on Mark as Answer button if this resolves your query.

    DezignCentric.com
    Web Design | Artwork Redraw | Graphic Design |
    Logo Design | PSD 2 XHTML | Business Identity design
Page 1 of 1 (2 items)