Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to print particular record form with its data without showing that form which is having data,...
it should be direct open print popup ( print preview form )..

here is my code which i am using to redirect to a page from sending query string on clicking grid view button:--
C#
else if (e.CommandName == "PrintRecord")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = grdOldAdmission.Rows[index];
string studentId = row.Cells[5].Text.ToString();
string CenterCode = (string)(Session["CenterCode"]);
Response.Redirect("~/Admission/PrintStudentDetails.aspx?StudentID=" + studentId + "&CenterCode=" + CenterCode + "&PageMode=PrintRecord");
}
Posted
Updated 14-Oct-14 21:25pm
v2
Comments
Sinisa Hajnal 15-Oct-14 2:14am    
What have you tried? Do you have code that doesn't work? What is your question (do not ask for finished code without showing that you tried few things)?
Shubh_0009 15-Oct-14 2:17am    
Actually i am getting record on a form that is showing particular clicked record,,,
But what i want that i don't wanna show that form except it i want to show print preview form to print it
Sinisa Hajnal 15-Oct-14 2:49am    
This comment has more information then the whole question above. Please use Improve question and describe the situation in more detail. You're more likely to get help with clearly defined problem.
What do you mean by "print preview form" - this is web site, why can't you just open a page formatted like it will look on paper? With the button for printing with @media print display:none;
Shubh_0009 15-Oct-14 2:52am    
Ok..I will try..
Actually i am new for asp.net and c# or really as a developer
Sinisa Hajnal 15-Oct-14 2:58am    
That is quite alright, we all were beginners at some point. But you can choose to be clear and concise or someone who doesn't know how to describe a problem. You can be a developer who solves his own problems by doing research and trying things and THEN asking or your can be "give me de codez" dabbler who has no clue about programming :)

Cheers for you being the former :)

1 solution

This is asp.net, only control you have over printing is by your pages rendred client side.

You can use the page you have and call javascript print function on window load...

This will cause the window to flicker for a moment and open printing dialog for the user.
JavaScript
$(window).load(function() {
window.print();

// instead of close you can redirect to the calling page
window.close();

});


Alternative is to create PDF or DOC file ready for printing, but there is nothing you can do that will force the user to print...except maybe via VBScript on IE (see here[^])

Same function here[^]

Mozzila can be configured to print without dialog, but you have to have access to client browser - if you're doing internal application for the firm in which you can enforce the browser use and setup each client, you can do this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900