473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Get browser window size from C# codebehind

How can we get the browser window size from C# codebehind? What's the
easiest way to do that?

Just D.
Nov 19 '05 #1
5 14209
> How can we get the browser window size from C# codebehind? What's the
easiest way to do that?


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

-Darrel
Nov 19 '05 #2
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" <no*****@hotmail.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl...
How can we get the browser window size from C# codebehind? What's the
easiest way to do that?


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

-Darrel

Nov 19 '05 #3
> 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.


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
Nov 19 '05 #4
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...
How can we get the browser window size from C# codebehind? What's the
easiest way to do that?

Just D.

Nov 19 '05 #5
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.

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?

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: bayram guzer | last post by:
hi everybody, i have very strange error. i can not see some of the asp pages on my browser. when i look from view source, all the source is there but browser does not show anything, just an empty...
8
by: Andrew Crook | last post by:
I placed the following code in my html file window.resizeTo(1000,700) window.moveTo((screen.availWidth/2)-(1000/2),(availHeight/2)-(700/2)); The resize seems to work fine, however, the move...
12
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical...
6
by: Wardeaux | last post by:
I can't find a way to open a new browser window from my codebehind. 1) My page does a postback to the server. 2) On server I evaluate whether to return to existing page or leave existing page...
9
by: Rathtap | last post by:
I want to popup a window from my codebehind. The reason is that during the postback the code needs to do some validations and to build the arguments that are passed in the url. How can I achieve...
1
by: Just D. | last post by:
How can we get the browser window size from C# codebehind? What's the easiest way to do that? Just D.
17
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I find the size of a browser window?...
0
by: toeffetommy | last post by:
Hello, I need a piece of functionality developed for our Website and I need some technical advice on how get there. Essentially, what I want to develop is a browser-within-browser...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.