设置页面高度

本文关键字:高度 设置 | 更新日期: 2023-09-27 18:07:57

我有一个搜索页面,在面板中有标准,当页面打开时,显然没有结果,页脚直接出现在搜索面板下面。如何将结果面板设置为设置高度,然后在找到搜索结果时拉伸为网格的高度。欢呼声

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="FrmSearch.aspx.cs" Inherits="web.FrmSearch" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <asp:UpdatePanel ID="pnlUpdate" runat="server" ChildrenAsTriggers="true">
        <ContentTemplate>
            <div id="divSearch">
                <asp:Panel ID="pnlSearch" runat="server" DefaultButton="BtnSearch">
                    <table width="100%">
                        <tr>
                            <td>
                                <asp:Label ID="LblName" runat="server" Text="Name:" CssClass="head2"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="TxtSurname" runat="server" Width="200" CssClass="norm"></asp:TextBox>
                            </td>
                            <tr>
                                <td>
                                    <asp:Label ID="LblAddress" runat="server" Text="Address:" CssClass="head2"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="TxtAddress" runat="server" Width="200" CssClass="norm"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:Button ID="BtnSearch" runat="server" Text="Search" OnClick="BtnSearch_Click" />
                                </td>
                                <td colspan="2" align="center">
                                    <asp:Button ID="BtnReset" runat="server" Text="Reset" OnClick="BtnReset_Click" />
                                </td>
                            </tr>
                    </table>
                </asp:Panel>
            </div>
            <div>
                <asp:Label ID="lblCount" runat="server" CssClass="head2"></asp:Label>
            </div>
            <hr />
            <div id="divResults">
                <asp:Panel ID="pnlResults" runat="server">
                    <asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="false" Width="99%"
                        CssClass="grd" OnRowDataBound="gvResults_RowDataBound">
                        <Columns>
                            <asp:TemplateField HeaderText="Name">
                                <ItemTemplate>
                                    <asp:HiddenField ID="hfGUID" runat="server" Value='<%# Bind("GUID")%>' />
                                    <asp:Label ID="LblName" runat="server" Text='<%# Bind("Name")  %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Address">
                                <ItemTemplate>
                                    <asp:Label ID="LblAddress" runat="server" Text='<%# Bind("Address") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Post Code">
                                <ItemTemplate>
                                    <asp:Label ID="LblPostCode" runat="server" Text='<%# Bind("Post_Code") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Telephone">
                                <ItemStyle Width="150px" />
                                <ItemTemplate>
                                    <asp:Label ID="LblTelephone" runat="server" Width="150px" Text='<%# Bind("Telephone") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </asp:Panel>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSearch" />
            <asp:AsyncPostBackTrigger ControlID="btnReset" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>

设置页面高度

您可以使用min-height:200pxdivSearch容器

#divSearch
{
  min-height:200px  //according to your requirement
}