|
I want to print the page in C#/ASP.NET 2.0, but the problem is when i use following javascript code, it prints the whole page.
function printMe()
{
window.print();
document.getElementById("printed").value = "YES";
How to print specified contents in .NET 2.0?
document.getElementById("form1").submit();
}
I don't want to print the complete page but i just want to print the contents of the page only.
Do anybody have any idea?
Thanks in advance
|
|
|
|
|
hello,
for this u just need to use css media.
u have to create a new print css and have to include in ur aspx page.
like this..
div#header
{
display:none;
}
may help u this.
Amit Agarwal
|
|
|
|
|
can u please explain this in bit detail?
|
|
|
|
|
Put the content that you want to print in Div tag and put class="Printable"
Now in javascript get all div tag and check for their class if it is preintable get its content then open a new Window put all conetent in that window and prin t that window
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
What I want to do is, I have an index.aspx page, where all banners, images, links, contents are there.There are about 50 aspx pages, so should i have to put all the page's contents in div tag?
|
|
|
|
|
No i think you have to print only index page right,
place the things that you want to print in different/ same div tag
are you dislaying 50 pages in index page ? No i think
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
This is the code that i m writing, but error comes
Error: Object doesn't support this property or method.
at content.print();
line............
function printMe()
{
var content = document.getElementById ("divData");
content.print();
}
|
|
|
|
|
No it is not right way content don't have preint functionality
do one thing give the class name as printable to that div and use the below method i know its not right but you don't know javascript properly
<br />
<script type="text/javascript"><br />
function Print()<br />
{<br />
var copy = document.documentElement.cloneNode(true);<br />
var headContent = copy.getElementsByTagName("head");<br />
var divs = copy.getElementsByTagName("div");<br />
var content = ""; <br />
<br />
<br />
content = '<html>';<br />
content += '<head>' + headContent[0].innerHTML + '</head>';<br />
content += '<body >';<br />
for(i=0; i < divs.length; i++) <br />
{ <br />
var div = divs[i];<br />
if(div.className == "Printable")<br />
{content += div.innerHTML;}<br />
else if(div.className == "NotPrintable" && div.innerHTML.length > 0)<br />
{content = content.replace(div.innerHTML,'');}<br />
}<br />
content += '\n</body></html>';<br />
var pWin = window.open('', 'Print','directories=0,height=480,width=578,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=yes');<br />
pWin.document.open();<br />
pWin.document.write(content);<br />
pWin.document.close();<br />
pWin.print();<br />
}<br />
</script><br />
<br />
Check this one<br />
<br />
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
bhavna816 wrote: I don't want to print the complete page but i just want to print the contents of the page only.
This is not possible. What you can do is put the content that needs to be printed on a new page, and that page should not contain any images/banners etc. When print option is initiated, redirect user to this page and open print dialog.
Hope this helps
|
|
|
|
|
No! There are so many pages in the website and if i make a different page for all pages, it will be wrong.
I want this through programming.I know we can print through javascript, but the whole page gets printed.
I want only the contents, not images etc.........
|
|
|
|
|
bhavna816 wrote: I want this through programming.I know we can print through javascript, but the whole page gets printed.
Then you could write your own print function which is not possible since your application is browser dependent. What is your website content ? Are you giving print option for all of your pages or any specific pages ?
One option you can do is, create a single print page and pass the page to be printed to this page. Give an internal request to the page using HttpWebRequest /Webclient . Write a powerful regular expression which finds all image tags from the response text. Replace those with empty string, and write the final string to your print page. And invoke javascript print option.
|
|
|
|
|
hello all,
I have a Problem i'm showing my total in footer template of datagrid but now i have to display the subtotal just above this footer column or to say within this column but above the total row.
hwo can i do this..
Amit Agarwal
|
|
|
|
|
the footer of a datagrid is also a datagrid row...so why don't u add another row above the footer and then give the value to specific column...
Koushik
|
|
|
|
|
Do you want to get the total in footer Template?
on RowDataBound Event of gridview,get values of perticular rows and set footer template.
if (e.Row.RowType == DataControlRowType.DataRow)
{
Totalvalues +=convert.ToInt32(((Lable)e.Rows.Findcontrol("lbl")).Text)
}
if (e.Row.RowType == DataControlRowType.Footer)
{
((Label)e.Row.FindControl("lblTotal")).Text=Totalvalues.ToString();
}
best regard
pathan
please don't forget to vote on the post that helped you.
|
|
|
|
|
i finding some document about write custom validation component in ASP.NET (C#)
Have anyones got it?
|
|
|
|
|
Could you elaborate a little ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
I want write a custom Validator control (like RequiredFieldValidator), now i finding some document, tutorial to do that.
Any Suggestions?
Thanks
|
|
|
|
|
OK that simple you can get n number of articles and documents on it
Or you can use Custum validator that is readily availble and add your logic (business ) there
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
i write a custom validator inherit from BaseValidator, and test it.
when i load web page with FireFox, a javascript doesn't work (view source and i see some javascript created by ASP.NET was missed (etc. ValidatorOnSubmit()) )
every thing was fine with IE(6.0)
???
i don't want use any js created by ASP.NET.
any suggestions?, thanks
|
|
|
|
|
hi there!!, how to write a custom control propertie like ControlToValidate
thanks
|
|
|
|
|
Is if Possible insert the text in Image Button in asp.net 2.0?
|
|
|
|
|
You can put text on top of an image. What are you doing right now ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How i can view image from access data base (long binary data) not use path, in Image component using VB.net
In asp.net I can view use image or how can i bind image to byte(binary)
Piyush Vardhan Singh
|
|
|
|
|
You can't, unless you want to send the user the image as a download, or in a new window. To put it inside a page with other things, it needs to exist in the file system.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
if i am not wrong ->If your image is in binary and you want to show that image in your page.
One way is convert your binary image to bitmap/Jpeg then show that image in image control or in page directly.
Google how to convert Binary image to specific form
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|