473,787 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

screen resolution

Have resW=screen.wid th; resH=screen.hei ght in javascript. How can I read
these values in ASP.NET source code - Page_Load function of code behind?

Any suggestions?
Nov 19 '05 #1
18 11647
You need to pass the values from client to server side. The standard way is
to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:BC******** *************** ***********@mic rosoft.com...
Have resW=screen.wid th; resH=screen.hei ght in javascript. How can I read
these values in ASP.NET source code - Page_Load function of code behind?

Any suggestions?

Nov 19 '05 #2
I've have the following in HTML code...
<script language="javas cript">
document.getEle mentById('resW' ) = window.screen.w idth;
document.getEle mentById('resH' ) = window.screen.h eight;
</script>
<input type=hidden name=resW id=resW runat=server>
<input type=hidden name=resH id=resH runat=server>

How can I access the values in ASP.NET (VB) code behind? I keep getting
null values when I use Request.Form("r esW") or resW.Value?

What am I missing?

"Eliyahu Goldin" wrote:
You need to pass the values from client to server side. The standard way is
to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:BC******** *************** ***********@mic rosoft.com...
Have resW=screen.wid th; resH=screen.hei ght in javascript. How can I read
these values in ASP.NET source code - Page_Load function of code behind?

Any suggestions?


Nov 19 '05 #3
David,

I can think of two things that may be happening.

The first is that there won't be any value in either of those fields until a
postback has occurred. The first time your code runs the page hasn't
displayed on the client and the javascript hasn't filled those fields.

The second (if the problem isn't the first) is that setting the controls as
runat="Server" may be interfering with the process. If you're going to use
Request.Form to get the values the controls don't have to be .Net controls.
You would only use runat="Server" if you want to reference the hidden inputs
as .Net server side controls. To do that you should declare them on your
page something like:

Protected WithEvents resW As System.Web.Html Controls.HtmlGe nericControl

(I typed that from memory, so double check the system declaration...)

But from the looks of things I would just remove the runat="Server" and then
do the Request.Form on postback only.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:9C******** *************** ***********@mic rosoft.com...
I've have the following in HTML code...
<script language="javas cript">
document.getEle mentById('resW' ) = window.screen.w idth;
document.getEle mentById('resH' ) = window.screen.h eight;
</script>
<input type=hidden name=resW id=resW runat=server>
<input type=hidden name=resH id=resH runat=server>

How can I access the values in ASP.NET (VB) code behind? I keep getting
null values when I use Request.Form("r esW") or resW.Value?

What am I missing?

"Eliyahu Goldin" wrote:
You need to pass the values from client to server side. The standard way
is
to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:BC******** *************** ***********@mic rosoft.com...
> Have resW=screen.wid th; resH=screen.hei ght in javascript. How can I
> read
> these values in ASP.NET source code - Page_Load function of code
> behind?
>
> Any suggestions?


Nov 19 '05 #4
Change to:

document.getEle mentById('resW' ).value = window.screen.w idth;
document.getEle mentById('resH' ).value = window.screen.h eight;

and use resW.Value.

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:9C******** *************** ***********@mic rosoft.com...
I've have the following in HTML code...
<script language="javas cript">
document.getEle mentById('resW' ) = window.screen.w idth;
document.getEle mentById('resH' ) = window.screen.h eight;
</script>
<input type=hidden name=resW id=resW runat=server>
<input type=hidden name=resH id=resH runat=server>

How can I access the values in ASP.NET (VB) code behind? I keep getting
null values when I use Request.Form("r esW") or resW.Value?

What am I missing?

"Eliyahu Goldin" wrote:
You need to pass the values from client to server side. The standard way is to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:BC******** *************** ***********@mic rosoft.com...
Have resW=screen.wid th; resH=screen.hei ght in javascript. How can I read these values in ASP.NET source code - Page_Load function of code behind?
Any suggestions?


Nov 19 '05 #5
DavidS wrote:
I've have the following in HTML code...
<script language="javas cript">
document.getEle mentById('resW' ) = window.screen.w idth;
document.getEle mentById('resH' ) = window.screen.h eight;
have you tried
document.getEle mentById('resW' ).value = window.screen.w idth;
document.getEle mentById('resH' ).value = window.screen.h eight;
instead? </script>
<input type=hidden name=resW id=resW runat=server>
<input type=hidden name=resH id=resH runat=server>

How can I access the values in ASP.NET (VB) code behind? I keep getting
null values when I use Request.Form("r esW") or resW.Value?

What am I missing?

"Eliyahu Goldin" wrote:

You need to pass the values from client to server side. The standard way is
to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:BC****** *************** *************@m icrosoft.com...
Have resW=screen.wid th; resH=screen.hei ght in javascript. How can I read
these values in ASP.NET source code - Page_Load function of code behind?

Any suggestions?


Nov 19 '05 #6
I still get nothing for resW.value!

"Eliyahu Goldin" wrote:
Change to:

document.getEle mentById('resW' ).value = window.screen.w idth;
document.getEle mentById('resH' ).value = window.screen.h eight;

and use resW.Value.

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:9C******** *************** ***********@mic rosoft.com...
I've have the following in HTML code...
<script language="javas cript">
document.getEle mentById('resW' ) = window.screen.w idth;
document.getEle mentById('resH' ) = window.screen.h eight;
</script>
<input type=hidden name=resW id=resW runat=server>
<input type=hidden name=resH id=resH runat=server>

How can I access the values in ASP.NET (VB) code behind? I keep getting
null values when I use Request.Form("r esW") or resW.Value?

What am I missing?

"Eliyahu Goldin" wrote:
You need to pass the values from client to server side. The standard way is to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:BC******** *************** ***********@mic rosoft.com...
> Have resW=screen.wid th; resH=screen.hei ght in javascript. How can I read > these values in ASP.NET source code - Page_Load function of code behind? >
> Any suggestions?


Nov 19 '05 #7
Yes - but getting nothing (vbNullstring) for values in ASP.NET

"Franck" wrote:
DavidS wrote:
I've have the following in HTML code...
<script language="javas cript">
document.getEle mentById('resW' ) = window.screen.w idth;
document.getEle mentById('resH' ) = window.screen.h eight;


have you tried
document.getEle mentById('resW' ).value = window.screen.w idth;
document.getEle mentById('resH' ).value = window.screen.h eight;
instead?
</script>
<input type=hidden name=resW id=resW runat=server>
<input type=hidden name=resH id=resH runat=server>

How can I access the values in ASP.NET (VB) code behind? I keep getting
null values when I use Request.Form("r esW") or resW.Value?

What am I missing?

"Eliyahu Goldin" wrote:

You need to pass the values from client to server side. The standard way is
to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:BC****** *************** *************@m icrosoft.com...

Have resW=screen.wid th; resH=screen.hei ght in javascript. How can I read
these values in ASP.NET source code - Page_Load function of code behind?

Any suggestions?

Nov 19 '05 #8
David,

After you bring up your page on the client do a view source and check the
hidden inputs and see if the value exists there or not.

If it doesn't, show us how you're calling the initial javascript on page
load.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:CE******** *************** ***********@mic rosoft.com...
I still get nothing for resW.value!

"Eliyahu Goldin" wrote:
Change to:

document.getEle mentById('resW' ).value = window.screen.w idth;
document.getEle mentById('resH' ).value = window.screen.h eight;

and use resW.Value.

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:9C******** *************** ***********@mic rosoft.com...
> I've have the following in HTML code...
> <script language="javas cript">
> document.getEle mentById('resW' ) = window.screen.w idth;
> document.getEle mentById('resH' ) = window.screen.h eight;
> </script>
> <input type=hidden name=resW id=resW runat=server>
> <input type=hidden name=resH id=resH runat=server>
>
> How can I access the values in ASP.NET (VB) code behind? I keep
> getting
> null values when I use Request.Form("r esW") or resW.Value?
>
> What am I missing?
>
> "Eliyahu Goldin" wrote:
>
> > You need to pass the values from client to server side. The standard
> > way

is
> > to use hidden input controls:
> >
> > <input type=hidden runat=server id=inhResW>
> >
> > Eliyahu
> >
> > "DavidS" <Da****@discuss ions.microsoft. com> wrote in message
> > news:BC******** *************** ***********@mic rosoft.com...
> > > Have resW=screen.wid th; resH=screen.hei ght in javascript. How can
> > > I

read
> > > these values in ASP.NET source code - Page_Load function of code

behind?
> > >
> > > Any suggestions?
> >
> >
> >


Nov 19 '05 #9
Any example code I can review to get this to work is appreciated. I'd think
this wouldn't be complicated - but right now, I'm getting null values from
solutions recommended. Again, I simply want to read the screen resolution on
the client. In the ASP.NET code - after a postback, I simply then want to be
able to read these javascript values and do respective processing.

Please advise - I have 3 replies - and now seem confused by the solution
presented by all.
"S. Justin Gengo" wrote:
David,

I can think of two things that may be happening.

The first is that there won't be any value in either of those fields until a
postback has occurred. The first time your code runs the page hasn't
displayed on the client and the javascript hasn't filled those fields.

The second (if the problem isn't the first) is that setting the controls as
runat="Server" may be interfering with the process. If you're going to use
Request.Form to get the values the controls don't have to be .Net controls.
You would only use runat="Server" if you want to reference the hidden inputs
as .Net server side controls. To do that you should declare them on your
page something like:

Protected WithEvents resW As System.Web.Html Controls.HtmlGe nericControl

(I typed that from memory, so double check the system declaration...)

But from the looks of things I would just remove the runat="Server" and then
do the Request.Form on postback only.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:9C******** *************** ***********@mic rosoft.com...
I've have the following in HTML code...
<script language="javas cript">
document.getEle mentById('resW' ) = window.screen.w idth;
document.getEle mentById('resH' ) = window.screen.h eight;
</script>
<input type=hidden name=resW id=resW runat=server>
<input type=hidden name=resH id=resH runat=server>

How can I access the values in ASP.NET (VB) code behind? I keep getting
null values when I use Request.Form("r esW") or resW.Value?

What am I missing?

"Eliyahu Goldin" wrote:
You need to pass the values from client to server side. The standard way
is
to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discuss ions.microsoft. com> wrote in message
news:BC******** *************** ***********@mic rosoft.com...
> Have resW=screen.wid th; resH=screen.hei ght in javascript. How can I
> read
> these values in ASP.NET source code - Page_Load function of code
> behind?
>
> Any suggestions?


Nov 19 '05 #10

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

Similar topics

1
11069
by: ZaGras | last post by:
when my vb program run on another computer instead of my computer, the user interface is biggger..this is because of the screen resolution... anyone know how to solve pls?
23
4890
by: Dufe | last post by:
Hello all: To deal with the problem of differing user screen resolutions, I've explored: 1) making the pages in PHP, 2) having different pages on the same page and selecting the proper one via JavaScript, and 3) using fancy redirects and forced "back skip" redirects with cookies. Every approach has some fatal flaw as far as I have been able to persue it. My most recent idea is to make multiple style sheets (selectable via javascript...
5
4410
by: Chris | last post by:
After exhausting my search on the MS website, I can't find a straight answer. I fin dit hard to believe that MS left our something so useful in ASP.NET as screen resolution detection. Problem: I would like to detect, get values for, the screen resolution in px but in a code behind. Is this possible? There is a System.Windows.Forms.Screen class for the Windows client side, why are there none for browser/ASP.NET client?
4
15525
by: pjac | last post by:
I need some help with some VB language that will change the screen resolution on a monitor when a MS-Access 2000 database is opened from 1024 x 768 to 800 x 600. Any help with this effort would be deeply appreciated. Thanks in advance....
1
2174
by: fabrice | last post by:
Hi, I'm trying to get the screen resolution of the client and to realize a treatment in code behind. it seem to be hard. I can get information about the resolution with this following sub, call in Page_Load.I fix the text of The Control Label. But no treatment is possible. If i try to keep out the text of this label in code behind, i have nothing. The variable is empty.
6
2680
by: Darian | last post by:
I am wondering how (if it is possible of course) I can change a users screen resolution to a certain size when running my application and then change it back when they exit my application. For instance, if the users screen size is 800x600, I want the resolution to change to 1260x780 when running my program and then change back to 800x600 when exiting my program. Thanks, Darian
5
6208
by: Maxi | last post by:
I have a 30X16 cells table in my html page. Table height and width are set to 100%. I have set size of every cell inside the table to 24 pixel. When I open the html page in maximize state in either resolution 800 X 600 or 1152 X 864 it takes up the entire explorer size. In screen resolution 800 X 600, if I insert a pictures of 24 X 24 pixel in the cells it takes up the entire cell size (ideally it should as the cell size is also 24 X...
9
3908
by: Steve Wright | last post by:
Hi I'm developing a webpage that needs to include a different stylesheet depending on the screen resolution. I know that I could read the resolution in javascript and then do some sort of stylesheet switcher as part of the onload event but I would rather link in the correct stylesheet for the resolution in the first place.
1
2506
by: nasima khan | last post by:
Hi, i am nasima. I have got a code for setting the screen resolution of my page, but i am unable to understand. Can any one give a complete data explanation of the below code. Sub ChangeRes(X As Long, Y As Long, Bits As Long) Dim DevM As DEVMODE, ScInfo As Long, erg As Long, an As VbMsgBoxResult 'Get the info into DevM erg = EnumDisplaySettings(0&, 0&, DevM) 'This is what we're going to change DevM.dmFields =...
10
44087
by: =?Utf-8?B?UmljaA==?= | last post by:
A lot of users at my workplace use different screen resolutions, and I build apps to use 1680 x 1050 pixels res by default. But some users are using 800 x 600, and the apps are too large for their screen. I used to write code in Java a few years ago (2005), and you could stretch a form with the mouse and all the controls and fonts would resize to larger or smaller size. Does .Net framework 3.5 support this kind of functionality? Or -...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
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...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
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...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
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
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.