.NET Discussion

.NET Issues, Problems, Code Samples, and Fixes

ASP.NET: How To Get Browser Dimensions?

I’ve run across the issue of how to pull up the browser dimensions without using javascript.  One would think that Request.Browser.ScreenPixelsHeight and .ScreenPixelsWidth would suffice, right?  Well, no. Unfortunately, this only returned 640 x 480 every time I refreshed the page in different dimensions of browser window and at different resolutions.  What exactly does this “640 x 480” actually mean? I can’t seem to put my finger on it. 

It would be nice to know (without depending on Javascript) what the user’s dimensions are for a certain image of which I want to show a blowup using the ModalPopupExtender.  As it is, since the ModalPopupExtender freezes the panel in place regardless of scrolling, if my image is too big, some browsers won’t see everything, so I would like to give users with smaller browsers a scaled-down blowup image.  I suppose a little Javascript to determine these dimensions wouldn’t hurt since they have to have it on to use the ModalPopupExtender anyways, but I try not to depend on Javascript for functionality.  Anyone have any insight?  Thanks!

August 22, 2007 Posted by | ASP.NET, Javascript, ModalPopupExtender | 1 Comment

ASP.NET and Javascript: Accessing Server Side Code?

While writing some code today, I had an idea to improve user experience with a smidge of Javascript. Basically, click on a picture to show its enlarged version (using a ModalPopupExtender), and then on close, run some Javascript to have the appropriate radio button be selected for the image the user just looked at.  No problem, two lines of Javascript, and I don’t even know it that well (although, ASP.NET makes it a pain in the arse to match up control ID’s since they mangle them at run time.  If you’re having problem with ASP.NET changing control ID’s, run your app and check the source code.  Usually your control’s ID is something like “ctl00_somePanel_yourControlID”). 

However, I wanted to run some additional events when certain radio buttons were selected, like hiding or showing certain other panels.  This is easy on the back end, but since I’m already running the ModalPopupExtender, the server side “OnClick” event for the button doesn’t actually fire.  Rather than write some more Javascript to cover all the different permutations of possibilities that could occur, I would rather invoke the server side code once the Javascript has stopped running.  I found this article about Remote Scripting at the Code Project, but it seems far too complex for what I want to do.

Anyone have any ideas on how to call server side code via Javascript?  Or should I just suck it up and have my viewers suffer a postback?  Or better yet, is there a way to get the “OnCheckedChanged” (for the radio button) event to fire from the Javascript, rather than actually calling the server side code?

August 20, 2007 Posted by | ASP.NET, Javascript, ModalPopupExtender | 3 Comments

ASP.NET AJAX Toolkit: ModalPopupExtender Issues in IE6

While working on my newest creation, PROUDWear Sports, I’ve run into a little snag trying to implement the ModalPopupExtender.  Of course it works fine in IE7 and FireFox, but in IE6, it just refuses to work correctly.  I’m pretty sure that I’ve implemented it correctly, but one can never be too sure. I watched the How Do I: Use the ASP.NET AJAX ModalPopup Extender Control video provided by Microsoft and followed it pretty much exactly, except including my own functionality (which is essentially nothing! Basically showing a picture in the hidden panel with a close button, that’s it.) and still it refuses to work in IE6.

I posted in the ASP.NET forums about my issue a few minutes ago, detailing my total problem (6th post down, you can find it by searching for “.NET Discussion”). If you don’t want to go there, basically what happens is in IE6, instead of properly displaying the chosen modal panel, it displays the panel inline with the rest of the page and then goes modal, rendering the page inaccessible to the user.

If anyone has any suggestions, please please let me know.  Thanks!

Status: Solved! (8/17/07)
Solution: Upgrade your AJAX Toolkit DLL. This version is not the newest version, but the ModalPopupExtender functions correctly in IE6 when this one is applied.  I am not using the latest version because the accordion control does not function correctly in the newer versions.  When they fix that, I will go to the newest version.


August 14, 2007 Posted by | AJAX, AJAX Toolkit, ASP.NET, Bugs, CSS, FireFox, IE6, IE7, ModalPopupExtender | 20 Comments