Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm making a project on ASP.NET and I've the resolution 1280x800. I'm using the width of the web page 1245px which is running very fine on my system but when I'm using the site on the resolution 1024x768 then the alignment goes out of the browser. I'm using <div> width 1245px which is looking nice on the resolution of the 1280x800.
I tried this code but it is giving me error.



protected void Page_Load(object sender, EventArgs e)<br />
    {<br />
        div1.Style.Add(HtmlTextWriterStyle.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width.ToString());<br />
    }

It is giving error that

The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)`

I know that this code is for the windows form. So is there any simple way to fix it? Is there a way to set the resolution through getting the system resolution and adjust it according to that?
I've set the width of the
and some tables to 1245px how to handle them in that case?
Posted
Comments
Philippe Mori 22-Oct-11 13:31pm    
First of all, you typically want your page to fit in 1024 pixels... Normally, if the width of the content is larger than the width of the browser a scrollbar is displayed and the content is left justified. But you should typically avoid horizontal scrollbar (at least for a width of 1024 pixels when the browser is maximized).

You got that error because you are trying to use a windows form in side your asp.net means web form application..

and for your solution try to get your screen resolution using javascript
like this...

JavaScript
<script type="text/javascript">
    function detecteScreenResolutions() {
        var width = screen.width;
        var height = screen.height;
        alert("YOUR SCREEN RESOLUTION IS "+width +" x "+height);
    }
</script>


and as per this functin result set your css classes of your div..
 
Share this answer
 
C#
protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(" <script language='JavaScript'> window.moveTo(0,0); window.resizeTo(screen.width,screen.height); </script>");
        }
 
Share this answer
 
Comments
Richard Deeming 10-Dec-14 15:15pm    
Why are you answering a question from three years ago?!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900