0

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.

3
Contributors
2
Replies
14
Views
4 Years
Discussion Span
Last Post by ggamble
0

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.

0

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;

Edited by ggamble

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.