Connecting Tech Pros Worldwide Forums | Help | Site Map

Get browser window size from C# codebehind

Just D.
Guest
 
Posts: n/a
#1: Nov 19 '05
How can we get the browser window size from C# codebehind? What's the
easiest way to do that?

Just D.



darrel
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Get browser window size from C# codebehind


> How can we get the browser window size from C# codebehind? What's the[color=blue]
> easiest way to do that?[/color]

You'd have to grab the information client side with javascript and send it
back to the server on postback.

-Darrel


Just D.
Guest
 
Posts: n/a
#3: Nov 19 '05

re: Get browser window size from C# codebehind


HI Darrel,

I will try to explain. The significant headache is to create a universal
interface fitting any screen size. If the user resizes the browser it's a
good idea to adopt the interface to its needs. I'm trying to replace some of
the rulers made by JPG/GIF images by something more flexible like panels, or
simply drawing on the form, it's possible but I need to know the real size
of current frame where I'm drawing on. That's why this question appeared.
From one size I could use something standard like fill the frame, etc. but
if I need to modify the color using the position of the line it's harder, I
need to know the line length to draw it correctly.

If anybody can propose anything more efficient it would be nice, but I'm
currently seeing only this solution.

If I could get the browser window/frame size while the user resizes it, then
it would solve these problems because it's possible to recreate the
graphics, it's fast.

Another one method is - to use JAVA scripts to draw on the remote side
directly without any post backs. More efficient way, but is it really easier
for programming?

Just D.

"darrel" <notreal@hotmail.com> wrote in message
news:O%23jHqtWNFHA.1396@TK2MSFTNGP10.phx.gbl...[color=blue][color=green]
>> How can we get the browser window size from C# codebehind? What's the
>> easiest way to do that?[/color]
>
> You'd have to grab the information client side with javascript and send it
> back to the server on postback.
>
> -Darrel
>
>[/color]


darrel
Guest
 
Posts: n/a
#4: Nov 19 '05

re: Get browser window size from C# codebehind


> I will try to explain. The significant headache is to create a universal[color=blue]
> interface fitting any screen size. If the user resizes the browser it's a
> good idea to adopt the interface to its needs. I'm trying to replace some[/color]
of[color=blue]
> the rulers made by JPG/GIF images by something more flexible like panels,[/color]
or[color=blue]
> simply drawing on the form, it's possible but I need to know the real size
> of current frame where I'm drawing on. That's why this question appeared.
> From one size I could use something standard like fill the frame, etc. but
> if I need to modify the color using the position of the line it's harder,[/color]
I[color=blue]
> need to know the line length to draw it correctly.[/color]

Consider using CSS for this. You can do what you are talking about, but it's
typically much easier to just use CSS.

For instance, if you have a rule, you can just assign a border to a div set
to 100% width, and it will resize as needed.

Redrawing the interface on postback based on viewport size is certainly
doable, but not really sure if it's worth the effort.

-Darrel


William F. Robertson, Jr.
Guest
 
Posts: n/a
#5: Nov 19 '05

re: Get browser window size from C# codebehind


I don't think you can even get the browser size beyond using the client side
function getBoundingClientRect(), but I haven't had any luck really
determining the size of the browser. There is also a screen.width,
screen.height property that will return the screen resolution the browser is
on.

If you do find a way, you will need to send this information back to the
server, so you can do something with it. Plus, what will stop your user
from resizing their browser window?

HTH,

bill


"Just D." <no@spam.please> wrote in message
news:0jE2e.2522$k57.1466@fed1read07...[color=blue]
> How can we get the browser window size from C# codebehind? What's the
> easiest way to do that?
>
> Just D.
>
>[/color]


Just D.
Guest
 
Posts: n/a
#6: Nov 19 '05

re: Get browser window size from C# codebehind


Thanks, William,

I found a better way - all controls are using %% instead of pixels and it
works just great and on the client side. Yes, it brings some disadvantages
during development, but it price is good - the convenient resizable
interface.

Just D.

[color=blue]
>I don't think you can even get the browser size beyond using the client
>side
> function getBoundingClientRect(), but I haven't had any luck really
> determining the size of the browser. There is also a screen.width,
> screen.height property that will return the screen resolution the browser
> is
> on.
>
> If you do find a way, you will need to send this information back to the
> server, so you can do something with it. Plus, what will stop your user
> from resizing their browser window?[/color]


Closed Thread