Solved

how do I make this print button work?

Posted on 2011-02-13
9
451 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
  • 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Entity Framework 7 43
Delete HTML table rows 12 31
ASP.net Fit 3 divs on screen side by side 3 30
Convert Select to DropDownListFor MVC 5 2 17
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

831 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