TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shal
1.5k
245
3.8k
RDLC ReportViewer Print preview not showing
Apr 5 2021 7:12 AM
I have added a button using javascript to preview and print but images are loaded into a Print preview.
The photos(images) are not appearing in the Print preview.
find the image attached for reference.
kindly check my code.
<script type=
"text/javascript"
>
function
printReport(report_ID) {
var
rv1 = $(
'#'
+ report_ID);
var
iDoc = rv1.parents(
'html'
);
// Reading the report styles
var
styles = iDoc.find(
"head style[id$='ReportControl_styles']"
).html();
if
((styles == undefined) || (styles ==
''
)) {
iDoc.find(
'head script'
).each(
function
() {
var
cnt = $(
this
).html();
var
p1 = cnt.indexOf(
'ReportStyles":"'
);
if
(p1 > 0) {
p1 += 15;
var
p2 = cnt.indexOf(
'"'
, p1);
styles = cnt.substr(p1, p2 - p1);
}
});
}
if
(styles ==
''
) { alert(
"Cannot generate styles, Displaying without styles.."
); }
styles =
'<style type="text/css">'
+ styles +
"style>"
;
//--- Reading the report html
var
table = rv1.find(
"div[id$='_oReportDiv']"
);
if
(table == undefined) {
alert(
"Report source not found."
);
return
;
}
//-- Generating a copy of the report in a new window
var
docType =
''
;
var
docCnt = styles + table.parent().html();
var
docHead =
'<head><title>Printing ...title><style>body{margin:5;padding:0;}style>head>'
;
var
winAttr =
"location=yes, statusbar=no, directories=no, menubar=no, titlebar=no, toolbar=no, dependent=no, width=720, height=600, resizable=yes, screenX=200, screenY=200, personalbar=no, scrollbars=yes"
; ;
var
newWin = window.open(
""
,
"_blank"
, winAttr);
var
childWindow = window.open(
'Print.aspx'
,
'PrintMe'
,
'width=900,resizable=1,scrollbars=1'
);
writeDoc = newWin.document;
writeDoc.open();
writeDoc.write(docType +
'<html>'
+ docHead +
'<body onload="window.print();">'
+ docCnt +
'body>html>'
);
writeDoc.close();
// The print event will fire as soon as the window loads
newWin.focus();
// uncomment to autoclose the preview window when printing is confirmed or canceled.
// newWin.close();
};
function
printReportClick() {
printReport(
'<%=ReportViewer1.ClientID %>'
);
}
</script>
<asp:Button runat=
"server"
CssClass=
"btn-addschedule-bot"
Style=
"margin-left: 10px;"
ID=
"btnPrint"
CausesValidation=
"true"
ValidationGroup=
"vgSubmit"
OnClientClick=
"printReportClick();"
Text=
"Print Report"
/>
Attachment:
u.zip
Reply
Answers (
3
)
Update GridView.
How to Add [AllowAnonymous] for All Controllers in WEB API?