473,388 Members | 1,496 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,388 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 14207
> 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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.