or AJAX Toolkit PopupControl Extender -- Which is best for this?

I am getting confused as to the best way to proceed on this problem -- not a new event for me but still frustrating. I have a building reservation situation where I store building use information in a SQLServer Express database and display it on a calendar. What I want to be able to do is click on the day and have a popup form appear with a detail view of the building use data for that day. The user should be able to edit the data and save it to the database.

In searching for information on the PopupControlExtender I came across the method of displaying another window. Here are my questions:
1. What is the best way to do what I want to do? An entirely different approach may be best. I don't know.
2. What options do I have if the user has disabled Java or disabled popups?

I am a true novice when it comes to web development. Examples and links to beginner level tutorials would be greatly appreciated.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

GewgalaConnect With a Mentor Commented:
I would go with the PopupControlExtender, as that opens an in-page modal window (just a floating container such as a div) rather than which opens a whole new browser window (a.k.a. pop up window that most people have blockers installed to prevent).

The trick to get links that execute javascript code to still execute when javascript is disabled, is to use the event.preventDefault() method in non-IE browsers, and event.returnValue = false; in IE.


<a href="myDetailsPage.aspx?id=5" onclick="showDetails(5, event)">Details</a>

Open in new window

Inside the showDetails JavaScript function you have:

function showDetails(buildingId, e)
     // put code here that programmatically executes/shows your PopupControlExtender
     // the particular link that calls this function in the above example passes in a buildingId of 5
     // which you can use to show specific data about building 5

     // after you show the pop up content via your PopupControlExtender, 
     // the following code will prevent the href="myDetailsPage.aspx" on the link from executing
     if (e.preventDefault)  // non IE browsers
           e.returnValue = false;  // IE browsers

Open in new window

With the above code, the link "Details" is set to go to the page "myDetailsPage.aspx?id=5".  The link also has an onclick event that points to a method that accepts the buildingId value as well as the event handler of the click event (the e parameter inside the javascript function).  Inside that function, you use the buildingId value in your display of the details pop up on the client.  That function continues to then stop execution of href value on the original link when the user clicked on it.  As a result, javascript was used to stop the browser from navigating to myDetailsPage.aspx?id=5.  

This works well because when JavaScript is disabled, the regular function of the link will not be stopped and the browser will instead navigate to myDetailsPage.aspx?id=5 where you can have code in that page that listens for a get parameter query string of "id" and use it's value to display building 5's content.

rkulpAuthor Commented:

Thanks for your quick response. The situatuion is not quite what you have stated but theoretically equivalent. The user clicks on a date in the calendar and that date is what is needed for the query to show the details about the building. However, that difference leads to one more problem. How do I fire the PopupControlExtender from the Calendar.selectionChanged event rather than a button onClick event? That is, how do I execute showDetails from the calendar code behind? The only example I can find uses <asp:ModalPopupExtender> which I cannot find anywhere, either in VS2005 or VS2010. That control had a show method but the PopupControlExtender does not.
rkulpAuthor Commented:

I found the <ajax:ModalPopupExtender> and can show the popup from the calendar's selectionchanged event. However, it is an empty panel except for a "close" button. It seems I have considerable work to do. I'll get back in a day or so to give you and update and, hopefully, close the question. Thanks for your help.
rkulpAuthor Commented:
Thanks for your excellent response. It was very clear, even to a novice.
Glad I could help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.