1

I am using .net 2005. In that i have master page and content page, i am using panel inside content.

Is any body know how to set panel width as per screen size at run time ??

Thanks

4

2 回答 2

3

Set a css class attribute on your panel

<asp:Panel CssClass="fullWidth" ID="MyPanel" runat="server">
</asp:Panel>

Then link to an external css stylesheet from your master page an in that set the following

.fullWidth
{
    width: 100%;
}

NOTE: This sets the width of any element with class fullWidth to 100% of the width of it's parent and can be used for other elements also

于 2009-03-03T14:27:59.380 回答
2

Add a javascript function on onload event on the body tag to resize your panel width.

Note, this code has been typed without syntax verification.

<script language="javascript" type="text/javascript">
    function Resize(item, width)
    {
        document.getElementById(item).width = width;
    }
</script>

<body onload="Resize(<%= Mypanel.ClientID %>, screen.width)">
于 2009-03-03T14:27:23.563 回答