I am using C# in VB 2012 I want to know how to print the contents of a textbox.

Example if someone types "John" in a txtFirstName.text I want to print "Thank you , John "
on a new page which will get print.

A second problem I have is that when I print that new page the URL of the page gets printed also
I would like a way to prevent the URL being printed.

it would help if you post what code you have so far so we can see exactly what you are doing and provide guidance on how to fix it.

However, in general...

Example if someone types "John" in a txtFirstName.text I want to print "Thank you , John " on a new page which will get print.

If you want to display this in a new page, you will need to send information to the new page, specifically the contents of the textBox. I'm assuming ASP.NET because you posted in this forum category. So, you'll have a textbox control and a submit button. What you need to do is create an event handler for the submit button. In your C# code, you can use response.redirect, specify the page name and send the textbox contents using a query parameter. Something like this...

Response.Redirect("someOtherPage.aspx?q=" + textBox1.Text)

A second problem I have is that when I print that new page the URL of the page gets printed also I would like a way to prevent the URL being printed.

We need to see your code.

Use a Session[] ...

Session["Name"] = null;
Session["Name"] = txtBox.Text.Trim();

then in the page that your printing with, use it like so ...

string sName = Session"Name"] != Null ? Session["Name"].ToString() : string.Empty;
lblName.Text = sName;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.