print gridview but not print template fields

G

Guest

In my gridview I have 2 -3 template fields which are hyperlinks. I allow the
user to print this grid. When the grid prints it also prints the links, how
can I take the user to a print preview page and not show the templated
fields, (hyperlinks) and also not print those fields?
 
G

Guest

do you have an example or now of an example somewhere?

Eliyahu Goldin said:
Two client-side events onbeforeprint and onafterprint are designed to change
the page appearance before printing and to restore it after printing. You
can find the links and hide/show them in these events with javascript.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


CSharpguy said:
In my gridview I have 2 -3 template fields which are hyperlinks. I allow
the
user to print this grid. When the grid prints it also prints the links,
how
can I take the user to a print preview page and not show the templated
fields, (hyperlinks) and also not print those fields?
 
G

Guest

here's the problem i'm running into.
I'm using a master page and the gridview is in the content section. The grid
view has 2 or 3 columns (based on the page) that are links using a template
field and <a href=> for the links. When the user clicks my print button, I
take them to a print preview page which is like a snap shot of the page but
without the master page surrounding it.

Here is my code I'm using. (if there is another easier way, I'm all for it)
this is my print preview page only:
<script language=javascript>
function printpr(OLECMDID)
{
if (opener && !window.opener.closed)
{
document.writeln(opener.document.getElementById('tbl').outerHTML);
}
}
</script>
<table cellpadding="0" cellspacing="0" border="0" width="100%" align=left>
<tr>
<td class="td_heading" width=100% align=left>
<asp:GridView ID="GridView1" runat="server" Width=100%>
</asp:GridView>
<script language="javascript" type="text/javascript">
document.writeln(opener.document.title);
</script>
</td>
</tr>
<tr>
<td class="td_general">
<script language="javascript" type="text/javascript">
<!--//
printpr(7);
//-->
</script>
</td>
</tr>
</table>
so what this is doing is taken the control (gridview in this case) from the
main page and showing it on the print page just as it is on the page. So I
need to remove the template field (link) on or before they ever show in the
print preview page


Eliyahu Goldin said:
What would you like to see in the example? How to use the events or how to
find the links?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


CSharpguy said:
do you have an example or now of an example somewhere?

Eliyahu Goldin said:
Two client-side events onbeforeprint and onafterprint are designed to
change
the page appearance before printing and to restore it after printing. You
can find the links and hide/show them in these events with javascript.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


In my gridview I have 2 -3 template fields which are hyperlinks. I
allow
the
user to print this grid. When the grid prints it also prints the links,
how
can I take the user to a print preview page and not show the templated
fields, (hyperlinks) and also not print those fields?
 
E

Eliyahu Goldin

Two client-side events onbeforeprint and onafterprint are designed to change
the page appearance before printing and to restore it after printing. You
can find the links and hide/show them in these events with javascript.
 
E

Eliyahu Goldin

What would you like to see in the example? How to use the events or how to
find the links?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


CSharpguy said:
do you have an example or now of an example somewhere?

Eliyahu Goldin said:
Two client-side events onbeforeprint and onafterprint are designed to
change
the page appearance before printing and to restore it after printing. You
can find the links and hide/show them in these events with javascript.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


CSharpguy said:
In my gridview I have 2 -3 template fields which are hyperlinks. I
allow
the
user to print this grid. When the grid prints it also prints the links,
how
can I take the user to a print preview page and not show the templated
fields, (hyperlinks) and also not print those fields?
 
A

addup

CSharpguy said:
here's the problem i'm running into.
I'm using a master page and the gridview is in the content section. The grid
view has 2 or 3 columns (based on the page) that are links using a template
field and <a href=> for the links. When the user clicks my print button, I
take them to a print preview page which is like a snap shot of the page but
without the master page surrounding it.

Here is my code I'm using. (if there is another easier way, I'm all for it)
this is my print preview page only:
<script language=javascript>
function printpr(OLECMDID)
{
if (opener && !window.opener.closed)
{
document.writeln(opener.document.getElementById('tbl').outerHTML);
}
}
</script>
<table cellpadding="0" cellspacing="0" border="0" width="100%" align=left>
<tr>
<td class="td_heading" width=100% align=left>
<asp:GridView ID="GridView1" runat="server" Width=100%>
</asp:GridView>
<script language="javascript" type="text/javascript">
document.writeln(opener.document.title);
</script>
</td>
</tr>
<tr>
<td class="td_general">
<script language="javascript" type="text/javascript">
<!--//
printpr(7);
//-->
</script>
</td>
</tr>
</table>
so what this is doing is taken the control (gridview in this case) from the
main page and showing it on the print page just as it is on the page. So I
need to remove the template field (link) on or before they ever show in the
print preview page


Eliyahu Goldin said:
What would you like to see in the example? How to use the events or howto
find the links?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


CSharpguy said:
do you have an example or now of an example somewhere?

:

Two client-side events onbeforeprint and onafterprint are designed to
change
the page appearance before printing and to restore it after printing.. You
can find the links and hide/show them in these events with javascript.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


In my gridview I have 2 -3 template fields which are hyperlinks. I
allow
the
user to print this grid. When the grid prints it also prints the links,
how
can I take the user to a print preview page and not show the templated
fields, (hyperlinks) and also not print those fields?

If your target browsers are advanced enough, a CSS solution may be
simpler
I typically use

@media Screen {
.PrintOnly { visibility:hidden; display:none; }
}
@media Print {
.ScreenOnly { visibility:hidden; display:none; }
}

set the css classes on the appropriate controls, and voilà!

Example:

<DIV class="PrintOnly" >I will not be visible in the browser, but I'll
show up in printouts (and print Preview) </DIV>
<DIV class="ScreenOnly" >I'm in the browser, but not in printouts (or
print Preview) </DIV>


Who needs pesky javascript :)

Hope this helps -
-- a --
 
G

Guest

that won't work in my scenario. Not with the links embedded into the grid as
such:

<asp:GridView ID="grdSales" runat="server" Font-Size="XX-Small"
BorderColor="#FFE0C0" BorderStyle="Solid" Width="100%" BorderWidth="1px"
Font-Names="Verdana,Arial,Helvetica" AutoGenerateColumns=False
CellPadding="1">
<HeaderStyle BackColor="Maroon"
ForeColor="LemonChiffon" Font-Size="XX-Small" BorderColor="Maroon"
BorderStyle="Solid" BorderWidth="1px" />
<FooterStyle
BackColor="Tan"></FooterStyle>
<Columns>
<asp:TemplateField HeaderText="H" >
<ItemTemplate>
<a class="smalldark" title="Details"
href="detail.aspx?Id=<%# Eval("portfolio_id") %>"">Sale Details</a><br />
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>

addup said:
here's the problem i'm running into.
I'm using a master page and the gridview is in the content section. The grid
view has 2 or 3 columns (based on the page) that are links using a template
field and <a href=> for the links. When the user clicks my print button, I
take them to a print preview page which is like a snap shot of the page but
without the master page surrounding it.

Here is my code I'm using. (if there is another easier way, I'm all for it)
this is my print preview page only:
<script language=javascript>
function printpr(OLECMDID)
{
if (opener && !window.opener.closed)
{
document.writeln(opener.document.getElementById('tbl').outerHTML);
}
}
</script>
<table cellpadding="0" cellspacing="0" border="0" width="100%" align=left>
<tr>
<td class="td_heading" width=100% align=left>
<asp:GridView ID="GridView1" runat="server" Width=100%>
</asp:GridView>
<script language="javascript" type="text/javascript">
document.writeln(opener.document.title);
</script>
</td>
</tr>
<tr>
<td class="td_general">
<script language="javascript" type="text/javascript">
<!--//
printpr(7);
//-->
</script>
</td>
</tr>
</table>
so what this is doing is taken the control (gridview in this case) from the
main page and showing it on the print page just as it is on the page. So I
need to remove the template field (link) on or before they ever show in the
print preview page


Eliyahu Goldin said:
What would you like to see in the example? How to use the events or how to
find the links?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


do you have an example or now of an example somewhere?

:

Two client-side events onbeforeprint and onafterprint are designed to
change
the page appearance before printing and to restore it after printing.. You
can find the links and hide/show them in these events with javascript.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


In my gridview I have 2 -3 template fields which are hyperlinks. I
allow
the
user to print this grid. When the grid prints it also prints the links,
how
can I take the user to a print preview page and not show the templated
fields, (hyperlinks) and also not print those fields?

If your target browsers are advanced enough, a CSS solution may be
simpler
I typically use

@media Screen {
.PrintOnly { visibility:hidden; display:none; }
}
@media Print {
.ScreenOnly { visibility:hidden; display:none; }
}

set the css classes on the appropriate controls, and voilà!

Example:

<DIV class="PrintOnly" >I will not be visible in the browser, but I'll
show up in printouts (and print Preview) </DIV>
<DIV class="ScreenOnly" >I'm in the browser, but not in printouts (or
print Preview) </DIV>


Who needs pesky javascript :)

Hope this helps -
-- a --
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top