0
我有一個打印頁面我只想顯示gridview並隱藏所有控件,我必須使用css。 我使用asp.net Ajax也用於我的頁面。 代碼FO我的網頁是和我想說明的部分是div標籤名蘋果HIde除了使用CSS打印的特定部分以外的所有部分
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:TabContainer ID="TabContainer1" runat="server" Width="1300px" ActiveTabIndex="0">
<asp:TabPanel ID="TabPanel1" runat="server">
<HeaderTemplate>
Engg.(Teaching)
</HeaderTemplate>
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>January</asp:ListItem>
<asp:ListItem>February</asp:ListItem>
<asp:ListItem>March</asp:ListItem>
<asp:ListItem>April</asp:ListItem>
<asp:ListItem>May</asp:ListItem>
<asp:ListItem>June</asp:ListItem>
<asp:ListItem>July</asp:ListItem>
<asp:ListItem>August</asp:ListItem>
<asp:ListItem>September</asp:ListItem>
<asp:ListItem>October</asp:ListItem>
<asp:ListItem>November</asp:ListItem>
<asp:ListItem>December</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem>2011</asp:ListItem>
<asp:ListItem>2012</asp:ListItem>
<asp:ListItem>2013</asp:ListItem>
<asp:ListItem>2014</asp:ListItem>
<asp:ListItem>2015</asp:ListItem>
<asp:ListItem>2016</asp:ListItem>
<asp:ListItem>2017</asp:ListItem>
</asp:DropDownList>
<br>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<div class="apple"> <asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"
DataSourceID="SqlDataSource1" OnRowDataBound="gv1" ShowFooter="True">
<FooterStyle CssClass="FooterStyle" />
<Columns>
<asp:TemplateField HeaderText="name" SortExpression="name">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Bind("name") %>' NavigateUrl='<%# "detailGenerated.aspx?id="+Eval("id") %>'
Target="_blank"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Act" SortExpression="name">
<ItemTemplate>
<asp:Button ID="Button9" runat="server" Text="Print" Target="_blank" PostBackUrl='<%# "Default.aspx?id="+Eval("id") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Designation" HeaderText="designation" SortExpression="designation" />
<asp:BoundField DataField="days" HeaderText="Days" SortExpression="days" />
<asp:BoundField DataField="basic_pay" HeaderText="Basic Pay" SortExpression="basic_pay" />
<asp:BoundField DataField="basic_paid" HeaderText="Basic Paid" SortExpression="basic_paid" />
<asp:BoundField DataField="da" HeaderText="DA" SortExpression="da" />
<asp:BoundField DataField="hra" HeaderText="HRA" SortExpression="hra" />
<asp:BoundField DataField="fma" HeaderText="FMA" SortExpression="fma" />
<asp:BoundField DataField="special_allow" HeaderText="Special Allow." SortExpression="special_allow" />
<asp:BoundField DataField="mobile_allow" HeaderText="Mobile Allow." SortExpression="mobile_allow" />
<asp:BoundField DataField="convey_allow" HeaderText="Convey Allow." SortExpression="convey_allow" />
<asp:BoundField DataField="spl_pay" HeaderText="Spl Pay" SortExpression="spl_pay" />
<asp:BoundField DataField="other_allow" HeaderText="Other Allow." SortExpression="other_allow" />
<asp:BoundField DataField="gross_salary" HeaderText="Gross Salary" SortExpression="gross_salary" />
<asp:BoundField DataField="cpf_ded" HeaderText="CPF Ded." SortExpression="cpf_ded" />
<asp:BoundField DataField="addl_cpf" HeaderText="Addl CPF" SortExpression="addl_cpf" />
<asp:BoundField DataField="cpf_rec" HeaderText="CPF Rec." SortExpression="cpf_rec" />
<asp:BoundField DataField="lic_fee" HeaderText="Lic Fee" SortExpression="lic_fee" />
<asp:BoundField DataField="water_charge" HeaderText="Water Charge" SortExpression="water_charge" />
<asp:BoundField DataField="elec_charge" HeaderText="Elec. Charge" SortExpression="elec_charge" />
<asp:BoundField DataField="i_tax_rec" HeaderText="I Tax Rec" SortExpression="i_tax_rec" />
<asp:BoundField DataField="other_rec" HeaderText="Other Rec" SortExpression="other_rec" />
<asp:BoundField DataField="total_ded" HeaderText="Total Ded" SortExpression="total_ded" />
<asp:BoundField DataField="net_pay" HeaderText="Net Pay" SortExpression="net_pay" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:employe %>"
SelectCommand="SELECT * FROM [generated] WHERE (([category] = @category) AND ([wing] = @wing) AND ([year] = @year) AND ([period] = @period)) ORDER BY [basic_pay] DESC">
<SelectParameters>
<asp:Parameter DefaultValue="Teaching" Name="category" Type="String" />
<asp:Parameter DefaultValue="Engineering" Name="wing" Type="String" />
<asp:ControlParameter ControlID="DropDownList2" Name="year" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="DropDownList1" Name="period" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel2" runat="server">
<HeaderTemplate>
Engg.(Non-teaching Staff)
</HeaderTemplate>
<ContentTemplate>
<asp:DropDownList ID="DropDownList3" runat="server">
<asp:ListItem>January</asp:ListItem>
<asp:ListItem>February</asp:ListItem>
<asp:ListItem>March</asp:ListItem>
<asp:ListItem>April</asp:ListItem>
<asp:ListItem>May</asp:ListItem>
<asp:ListItem>June</asp:ListItem>
<asp:ListItem>July</asp:ListItem>
<asp:ListItem>August</asp:ListItem>
<asp:ListItem>September</asp:ListItem>
<asp:ListItem>October</asp:ListItem>
<asp:ListItem>November</asp:ListItem>
<asp:ListItem>December</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList4" runat="server">
<asp:ListItem>2011</asp:ListItem>
<asp:ListItem>2012</asp:ListItem>
<asp:ListItem>2013</asp:ListItem>
<asp:ListItem>2014</asp:ListItem>
<asp:ListItem>2015</asp:ListItem>
<asp:ListItem>2016</asp:ListItem>
<asp:ListItem>2017</asp:ListItem>
</asp:DropDownList>
<br>
<asp:Button ID="Button2" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView2" runat="server" OnRowDataBound="gv2" AutoGenerateColumns="False"
DataKeyNames="id" DataSourceID="SqlDataSource2">
<FooterStyle CssClass="FooterStyle" />
<Columns>
<asp:BoundField DataField="Name" HeaderText="name" SortExpression="name" />
<asp:BoundField DataField="Designation" HeaderText="designation" SortExpression="designation" />
<asp:BoundField DataField="days" HeaderText="Days" SortExpression="days" />
<asp:BoundField DataField="basic_pay" HeaderText="Basic Pay" SortExpression="basic_pay" />
<asp:BoundField DataField="basic_paid" HeaderText="Basic Paid" SortExpression="basic_paid" />
<asp:BoundField DataField="da" HeaderText="DA" SortExpression="da" />
<asp:BoundField DataField="hra" HeaderText="HRA" SortExpression="hra" />
<asp:BoundField DataField="fma" HeaderText="FMA" SortExpression="fma" />
<asp:BoundField DataField="special_allow" HeaderText="Special Allow." SortExpression="special_allow" />
<asp:BoundField DataField="mobile_allow" HeaderText="Mobile Allow." SortExpression="mobile_allow" />
<asp:BoundField DataField="convey_allow" HeaderText="Convey Allow." SortExpression="convey_allow" />
<asp:BoundField DataField="spl_pay" HeaderText="Spl Pay" SortExpression="spl_pay" />
<asp:BoundField DataField="other_allow" HeaderText="Other Allow." SortExpression="other_allow" />
<asp:BoundField DataField="gross_salary" HeaderText="Gross Salary" SortExpression="gross_salary" />
<asp:BoundField DataField="cpf_ded" HeaderText="CPF Ded." SortExpression="cpf_ded" />
<asp:BoundField DataField="addl_cpf" HeaderText="Addl CPF" SortExpression="addl_cpf" />
<asp:BoundField DataField="cpf_rec" HeaderText="CPF Rec." SortExpression="cpf_rec" />
<asp:BoundField DataField="lic_fee" HeaderText="Lic Fee" SortExpression="lic_fee" />
<asp:BoundField DataField="water_charge" HeaderText="Water Charge" SortExpression="water_charge" />
<asp:BoundField DataField="elec_charge" HeaderText="Elec. Charge" SortExpression="elec_charge" />
<asp:BoundField DataField="i_tax_rec" HeaderText="I Tax Rec" SortExpression="i_tax_rec" />
<asp:BoundField DataField="other_rec" HeaderText="Other Rec" SortExpression="other_rec" />
<asp:BoundField DataField="total_ded" HeaderText="Total Ded" SortExpression="total_ded" />
<asp:BoundField DataField="net_pay" HeaderText="Net Pay" SortExpression="net_pay" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:employe %>"
SelectCommand="SELECT * FROM [generated] WHERE (([category] = @category) AND ([wing] = @wing) AND ([year] = @year) AND ([period] = @period)) ORDER BY [basic_pay] DESC">
<SelectParameters>
<asp:Parameter DefaultValue="Non-Teaching" Name="category" Type="String" />
<asp:Parameter DefaultValue="Engineering" Name="wing" Type="String" />
<asp:ControlParameter ControlID="DropDownList4" Name="year" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="DropDownList3" Name="period" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel3" runat="server">
<HeaderTemplate>
Engg.(Admn. Staff)
</HeaderTemplate>
<ContentTemplate>
<asp:DropDownList ID="DropDownList5" runat="server">
<asp:ListItem>January</asp:ListItem>
<asp:ListItem>February</asp:ListItem>
<asp:ListItem>March</asp:ListItem>
<asp:ListItem>April</asp:ListItem>
<asp:ListItem>May</asp:ListItem>
<asp:ListItem>June</asp:ListItem>
<asp:ListItem>July</asp:ListItem>
<asp:ListItem>August</asp:ListItem>
<asp:ListItem>September</asp:ListItem>
<asp:ListItem>October</asp:ListItem>
<asp:ListItem>November</asp:ListItem>
<asp:ListItem>December</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList6" runat="server">
<asp:ListItem>2011</asp:ListItem>
<asp:ListItem>2012</asp:ListItem>
<asp:ListItem>2013</asp:ListItem>
<asp:ListItem>2014</asp:ListItem>
<asp:ListItem>2015</asp:ListItem>
<asp:ListItem>2016</asp:ListItem>
<asp:ListItem>2017</asp:ListItem>
</asp:DropDownList>
<br>
<asp:Button ID="Button3" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView3" runat="server" OnRowDataBound="gv3" AutoGenerateColumns="False"
DataKeyNames="id" DataSourceID="SqlDataSource3">
<FooterStyle CssClass="FooterStyle" />
<Columns>
<asp:BoundField DataField="Name" HeaderText="name" SortExpression="name" />
<asp:BoundField DataField="Designation" HeaderText="designation" SortExpression="designation" />
<asp:BoundField DataField="days" HeaderText="Days" SortExpression="days" />
<asp:BoundField DataField="basic_pay" HeaderText="Basic Pay" SortExpression="basic_pay" />
<asp:BoundField DataField="basic_paid" HeaderText="Basic Paid" SortExpression="basic_paid" />
<asp:BoundField DataField="da" HeaderText="DA" SortExpression="da" />
<asp:BoundField DataField="hra" HeaderText="HRA" SortExpression="hra" />
<asp:BoundField DataField="fma" HeaderText="FMA" SortExpression="fma" />
<asp:BoundField DataField="special_allow" HeaderText="Special Allow." SortExpression="special_allow" />
<asp:BoundField DataField="mobile_allow" HeaderText="Mobile Allow." SortExpression="mobile_allow" />
<asp:BoundField DataField="convey_allow" HeaderText="Convey Allow." SortExpression="convey_allow" />
<asp:BoundField DataField="spl_pay" HeaderText="Spl Pay" SortExpression="spl_pay" />
<asp:BoundField DataField="other_allow" HeaderText="Other Allow." SortExpression="other_allow" />
<asp:BoundField DataField="gross_salary" HeaderText="Gross Salary" SortExpression="gross_salary" />
<asp:BoundField DataField="cpf_ded" HeaderText="CPF Ded." SortExpression="cpf_ded" />
<asp:BoundField DataField="addl_cpf" HeaderText="Addl CPF" SortExpression="addl_cpf" />
<asp:BoundField DataField="cpf_rec" HeaderText="CPF Rec." SortExpression="cpf_rec" />
<asp:BoundField DataField="lic_fee" HeaderText="Lic Fee" SortExpression="lic_fee" />
<asp:BoundField DataField="water_charge" HeaderText="Water Charge" SortExpression="water_charge" />
<asp:BoundField DataField="elec_charge" HeaderText="Elec. Charge" SortExpression="elec_charge" />
<asp:BoundField DataField="i_tax_rec" HeaderText="I Tax Rec" SortExpression="i_tax_rec" />
<asp:BoundField DataField="other_rec" HeaderText="Other Rec" SortExpression="other_rec" />
<asp:BoundField DataField="total_ded" HeaderText="Total Ded" SortExpression="total_ded" />
<asp:BoundField DataField="net_pay" HeaderText="Net Pay" SortExpression="net_pay" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:employe %>"
SelectCommand="SELECT * FROM [generated] WHERE (([category] = @category) AND ([wing] = @wing) AND ([year] = @year) AND ([period] = @period)) ORDER BY [basic_pay] DESC">
<SelectParameters>
<asp:Parameter DefaultValue="Administrative" Name="category" Type="String" />
<asp:Parameter DefaultValue="Engineering" Name="wing" Type="String" />
<asp:ControlParameter ControlID="DropDownList6" Name="year" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="DropDownList5" Name="period" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button3" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</asp:TabPanel>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
</asp:Content>
通過寫上打印機沒有這個CSS看起來它顯示空白頁。 – 2012-03-18 17:08:06