tags:

views:

1563

answers:

2

Hello Friends,

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

+2  A: 

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)">
Fabian Vilers
If you wait until the window.onload event to fire you could have the effect of the panel seemingly jumping to width seconds after the page loads
Nick Allen - Tungle139
i don't have body tag so where can i write this code ??
Kartik
If you don't have a body tag, you've got invalid HTML. It should always be <html><head></head><body></body></html> at the minimum.
Mufasa
+2  A: 

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

Nick Allen - Tungle139
Kartik asked about screen size, your solution, as you said, will only enlarge the panel to the parent width.
Fabian Vilers
how can i set it ? If u describe more i really appreciate..
Kartik
I figure, from Kartik's responses, this is what he actually wanted. I'm upvoting this.
Mufasa