Solved

how do I make this print button work?

Posted on 2011-02-13
9
447 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now