Solved

need help translating code to vb.net from c sharp

Posted on 2006-11-30
2
366 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now