We help IT Professionals succeed at work.
Get Started

jQuery, JavaScript and AJAX problems with ASP.NET

G_Hosa_Phat
G_Hosa_Phat asked
on
1,728 Views
Last Modified: 2014-05-24
Good afternoon, Experts.  I have been chasing my own tail for many, many days on this issue, and I'm hoping that someone here can point me in the right direction.  I am trying to implement an "idle timer" on my ASP.NET Web site to notify a user when their session is about to expire, and (hopefully) extend that session if the user chooses to do so.  I am building the site using Master Pages (VB), and the basic build is going just fine, but I seem to be having some issues when it comes to running certain jQuery/JavaScript/AJAX code on the pages.

I've tried using the offerings from the following pages, but none of them seem to work on my site for some reason:
http://www.techtalklive.org/ttlblog/Pages/Creating-Session-Expired-Countdown.aspx
http://pure-essence.net/2010/02/14/jquery-session-timeout-countdown/
http://code.msdn.microsoft.com/AspNetAlertSessionExpire-c230a148/sourcecode?fileId=56541&pathId=718504466

One commonality amongst these is that they are using jQuery, JavaScript and AJAX to accomplish the task of keeping the server-side session alive.  So, you might think the issue is with my browser (IE 11), but I have tried this in three different browsers (IE, Firefox and Chrome), and they all give the same basic results.  No warning dialog appears ever.  I've even tried it from multiple computers/users, and I get the same result.

But here's the real kicker: I built a plain HTML page (no ASP controls, no master page, no code-behind files) with the exact same JavaScript/JQuery/AJAX code, and the timer works exactly like it's supposed to.  The dialog pops up on screen and allows me to click "OK" to extend the session.  This leads me to believe the issue isn't with browser security settings, or any of that craziness.

What's interesting to note is that when I use the first example above with a timeout of 0 milliseconds (so the dialog should be appearing immediately), my TextBox functionality goes haywire - in IE the TAB key doesn't move me between fields, in Firefox I can't even type into any of the TextBoxes.  This seems to indicate that the dialog thinks it's showing itself, but it never actually appears on the screen.

One last little bit of info to throw out there is that there are some basic JavaScript blocks that do work correctly, such as the following:
<SCRIPT LANGUAGE="javascript">
<!-- // Javascript Email Address Encoder
var first = 'ma';
var second = 'il';
var third = 'to:';
var address = 'helpdesk';
var domain = 'example';
var ext = 'com'; 
document.write('<a href="');
document.write(first+second+third);
document.write(address);
document.write('@');
document.write(domain);
document.write('.');
document.write(ext);  
document.write('">'); 
document.write('</a>');
// -->
</script>

Open in new window

So, to sum up my question, is there possibly something in the IIS 7.5 configuration, or maybe even the web.config file that could be preventing the jQuery/JavaScript/AJAX functions from working correctly?  I feel like I've pored over these things a million times with no luck finding the culprit, and I'm about ready to start throwing things.  Thanks for all of your assistance.
Comment
Watch Question
Developer
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013
Commented:
This problem has been solved!
Unlock 5 Answers and 12 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE