Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

need help translating code to vb.net from c sharp

Posted on 2006-11-30
2
369 Views
Last Modified: 2010-04-16
Hi Guys,

I have some code that I am pretty sure will do exactly what I want it to do.  I have been working with it today, but I can't get it to work in vb.net.  It is code to get a printer friendly version of a web page to display.  By "Printer friendly version" I mean a web page without the headers and menues.  basically everything *except* the contents of the master page.

Here is the code in c sharp:

 protected void Page_Load(object sender, EventArgs e)
    {

        StringWriter sw = new StringWriter();

        //-- this will get my page, master page and all
        Server.Execute(Request.QueryString["Report"] + ".aspx", sw);

        //-- I shove the HTML in a string
        string report = sw.ToString();
       
        //-- I look for my start and end  of the content
        int iEnd = report.IndexOf("<!-- END REPORT -->");
        report = report.Substring(0, iEnd);

        int iStart = report.IndexOf("<!-- START_REPORT -->");

        //-- this is the page minus master page stuff
        report = report.Substring(iStart, iEnd-iStart);

        //-- shove this in a literal
        this.litReport.Text = report;

    }


********

My markup looks like this:

<body style="margin: 10px;">
    <form id="form1" runat="server">
        <div style="text-align: right;">
            <a href="#" onclick="print();">Print </a>
            <img src="images/spacer.gif" width="50px" height="1px" alt="" />
            <a style="text-decoration:underline; cursor:pointer" onclick="history.back();">Back</a>
        </div>
        <div>
            <asp:Literal ID="litReport" runat="server" />
        </div>
    </form>
</body>

}


If anyone could translate this code successfully into vb.net, it would be greatly appreciated.

Thanks,

Ryan



0
Comment
Question by:dchau12
2 Comments
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 200 total points
ID: 18049826
I don't know anything about web pages but the code should be:

        Dim sw As StringWriter = New StringWriter()

        ' -- this will get my page, master page and all
        Server.Execute(Request.QueryString("Report") & ".aspx", sw)

        ' -- I shove the HTML in a string
        Dim report As String = sw.ToString()
       
        ' -- I look for my start and end  of the content
        Dim iEnd As Integer = report.IndexOf("<!-- END REPORT -->")
        report = report.Substring(0, iEnd)

        Dim iStart As Integer = report.IndexOf("<!-- START_REPORT -->")

        ' -- this is the page minus master page stuff
        report = report.Substring(iStart, iEnd - iStart)

        ' -- shove this in a literal
        Me.litReport.Text = report
0
 
LVL 2

Accepted Solution

by:
amiableansari earned 300 total points
ID: 18051549
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question