Solved

how do I make this print button work?

Posted on 2011-02-13
9
454 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 250 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 250 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
Independent Software Vendors: 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 250 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 250 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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