Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Odd crash involving Javascript and a calendar control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
B. Chernick - 12 Dec 2007 15:30 GMT
I'm writing a web app in VB/Asp.net 2.0.  I have a screen with a detailsview.
In this detailsview are 2 template fields.  The first field contains a
dropdown list, a custom validator, and a hyperlink.  The second contains a
pair of calendar controls.  

I had what I thought was a neat little hack:  The validator for the dropdown
list calls a javascript function that both validates the dropdown (-1 means
nothing selected.) and updates the target of the hyperlink based on the value
of the dropdown list.  That part works fine.

The problem is that when I select a date on either calendar, the screen
crashes with the error: "Object reference not set to an instance of an
object."   The problem line is the first reference to the hyperlink in the
javascript code.  Since the calendars have nothing to do with these other
controls, I'm more than a little confused.   Here's the javascript code.  
(I've also tried Javascript error trapping but that doesn't seem to work
either.  Admittedly I'm a bit out of practice with JS.)

 function ValidateEmpDropdown(sender, args)
       {
           args.IsValid =  (new Number(args.Value)) >=  0;
           if ((new Number(args.Value)) >=0 )
               {
                   document.getElementById("<%= hlEmp.ClientId %>").href =
"EditEmployee.aspx?EmployeeId=" + (new Number(args.Value));
               }
               else
               {
               document.getElementById("<%= hlEmp.ClientId %>").href =
"DisplayEmployees.aspx";      
               }
           return args.IsValid;
       }
B. Chernick - 12 Dec 2007 17:25 GMT
Never mind.  Found the problem (or at least a temporary trial and error
solution.)  The hyperlink handle was being set in the DetailsView's databound
event.  I restored it on postbacks.  Now to look at calendar control
alternatives...

> I'm writing a web app in VB/Asp.net 2.0.  I have a screen with a detailsview.
>  In this detailsview are 2 template fields.  The first field contains a
[quoted text clipped - 29 lines]
>             return args.IsValid;
>         }

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.