473,796 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 14253
> 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*****@hotmai l.com> wrote in message
news:O%******** ********@TK2MSF TNGP10.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 getBoundingClie ntRect(), 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@fed1r ead07...
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 getBoundingClie ntRect(), 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
3538
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 page. Does anybody have idea about this ?
8
1913
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 does not seem to work. Tested under IE6 and firefox. I wish the browser to resize and centre on screen when the user goes to my site.
12
10177
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 scrollbar, you get the height of the entire document, screwing up any chance of centering a window in the browser using these values. Is there a way to get the height of the actual browser window and not the entire page height? Thanks.
6
4082
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 displayed and open new window with different page Seems easy enough, I've just not found the key element to make this happen. Anyone found the solution?? MTIA
9
3913
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 this functionality? The reason I do not want to use Response.Redirect is because when the user comes back to the first page, all the selections that were made(which are the arguments) disappear.
1
1365
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
2655
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I find the size of a browser window? ----------------------------------------------------------------------- Where supported in NN: (>NN4.0) var winWidth = window.innerWidth; var winHeight = window.innerHeight; Where supported in IE: (>IE4.0)
0
2521
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 functionality where the ‘mini-browser’ has similar functionality to a normal browser. Let me explain: Firstly, our website interface will open up in a popup window. All the normal browser toolbars and buttons have been removed from the popup window. It’s...
1
3813
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 properties alt in img tag istead of picture . place of the pictures is saved in the database(my database is with mysql) and in home page i fetch properties of the product and address of place that pictures is located output of the code in the...
0
9684
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10236
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7552
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6793
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.