Solved

need help translating code to vb.net from c sharp

Posted on 2006-11-30
2
371 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
[X]
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
2 Comments
 
LVL 86

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

732 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