?
Solved

how do I make this print button work?

Posted on 2011-02-13
9
Medium Priority
?
455 Views
Last Modified: 2012-05-11
<%@ Control Language="C#" AutoEventWireup="true"  %>



<style type="text/css">
    .style1
    {
        text-align: center;
        font-size: large;
    }
    .style2
    {
        text-align: center;
    }
    .style3
    {
        color: #00CC00;
        font-weight: bold;
    }
    .style4
    {
        color: #33CC33;
        font-size: x-large;
        text-align: center;
    }
    .style5
    {
        background-color: #FFFF99;
    }
    .style6
    {
        color: #FFFFCC;
        background-color: #FF0000;
         font-size: x-large;
   }
</style>
<asp:Button ID="Print" runat="server" Text="Button" />
<p class="style1">
    <span class="style6"> &nbsp;&nbsp;&nbsp;Lot 60 and Lot 61 in Woodland Subdivision</span></p>
<p class="style1">
    <span class="style6"> &nbsp;in White Hall, Arkansas &nbsp;&nbsp;</span></p>

<p class="style1">
    &nbsp;</p>
<p class="style1">
    &nbsp;</p>
<p class="style1">
The 25 feet wide access is part of the lot and it lead to the lot.  This way you will have your own independant driveway.  Please write contact us if you may have any questions. The price of each lot is $28,000.00
    &nbsp;</p>
<p class="style1">

<img alt="" src="../Pictures/Lots/lots6061satview.jpg" />
    &nbsp;</p>

<p class="style1">
These two lots are on Chipmunk road, behind house numbers 141 and 151,
White Hall, Ar-71602
   &nbsp;</p>

<p class="style1">

you may search,
http://maps.google.com


141 chipmunk road, White Hall, Ar-71602

   &nbsp;</p>
0
Comment
Question by:goodk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
9 Comments
 
LVL 9

Assisted Solution

by:xav056
xav056 earned 1000 total points
ID: 34884926
try this
<asp:Button ID="Print" runat="server" Text="Button"  OnClientClick="window.print();return false"/>

0
 

Author Comment

by:goodk
ID: 34885056
Oh, yeah thanks - but I wanted it to only print the control file or certain div area. Is it possible? how

myControlFile.ascx
0
 
LVL 9

Assisted Solution

by:xav056
xav056 earned 1000 total points
ID: 34885188
you will have to define this in the css, so in the css file put whatever you want printed  inside a   @media print section, and you will have to have the same css
in @media screen section, if you want the style to display
take a look at
http://www.digital-web.com/articles/css_styling_for_print_and_other_media/
http://www.w3schools.com/CSS/css_mediatypes.asp
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Assisted Solution

by:Anurag Agarwal
Anurag Agarwal earned 1000 total points
ID: 34886593
hello buddy just do the following thing ....

#### Print.css ###########

@media print
{
      Div.a {display :none  }
}

################

<div>
............ Your Control ascx drop it here.............
</div>

<div class="a">
....
....( for content you dont want to print, put all under this div like tables controls etc)
...

<asp:Button ID="btnPrint" runat="server" CssClass="btn" Font-Bold="True" OnClientClick="javascript:window.print()"  Text="Print" />

</div>

---------------------------

This will print only content of first div .............and leave everything under second div
thus you will get print out of your control

0
 

Author Comment

by:goodk
ID: 34892420
but how do I apply it to div if i have many classes?

can you kindly cut and paste my original page and show your solution - thanks
0
 
LVL 8

Assisted Solution

by:Anurag Agarwal
Anurag Agarwal earned 1000 total points
ID: 34894193
goodk in your code which part do u want to print ?? as i m not able to find any control draged in it ??

0
 

Author Comment

by:goodk
ID: 34897801
I am just pulling different control files in the center of the page, I only want to print CPHcontainer.
http://aceyourplace.com/Prod/ForSale.aspx?xControlFile=60_61_ChipmunkLots
thanks for your help


<%@ Page Title="" Language="C#" MasterPageFile="~/Prod/Main.Master" AutoEventWireup="true" CodeBehind="ForSale.aspx.cs" Inherits="AceYP_Oct2010.Prod.ForSale" %>
<script runat="server">


 //   protected override void OnPreInit(EventArgs e)

    protected void Page_Init(object sender, EventArgs e)
    {
        int loop1, loop2;
        string xValue = "4SiennaLakeCove";

        // Load NameValueCollection object.
        NameValueCollection coll = Request.QueryString;
        // Get names of all keys into a string array.
        String[] arr1 = coll.AllKeys;
        for (loop1 = 0; loop1 < arr1.Length; loop1++)
        {
           // Response.Write("Key: " + Server.HtmlEncode(arr1[loop1]) + "<br>");
            String[] arr2 = coll.GetValues(arr1[loop1]);
            for (loop2 = 0; loop2 < arr2.Length; loop2++)
            {
              //  Response.Write("Value " + loop2 + ": " + Server.HtmlEncode(arr2[loop2]) + "<br>");
                xValue = Server.HtmlEncode(arr2[loop2]);
            }
        }
        xValue = "~/Prod/" + xValue + ".ascx";
        Control control = LoadControl(xValue);

        Control placeHolderControl = Page.Controls[0].FindControl("CPHcontainer");
        placeHolderControl = placeHolderControl.FindControl("CPHcenterColumn");
        if (placeHolderControl != null)
        {
           //  placeHolderControl.Controls.Add(new LiteralControl("Added in Code to PH 2."));
            placeHolderControl.Controls.Add(control);
        }



        // placeHolderControl.Controls.Add(new LiteralControl("Added in Code."));
      //  placeHolderControl.Controls.Add(control);
        int cnt = Page.Controls.Count;
    }


   
    </script>
    <asp:Content ID="Content2" ContentPlaceHolderID="CPHrightColumn" runat="server">
        <img alt="" src="../Pictures/houses/Pics/Chipmunk1.jpg" width="140" height="120" />

        <img alt="" src="../Pictures/houses/Pics/DoubleSinks.jpg" width="140" height="120"/>
</asp:Content>
0
 

Accepted Solution

by:
goodk earned 0 total points
ID: 34956530
I am still waiting for a response!!

All I want to do is be able to print a section on the master pages.  so the user can print only a certain section.

thanks
0
 

Author Closing Comment

by:goodk
ID: 35067593
did not quiet answered the question - but I got the idea what to do
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month11 days, 23 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question