Will "the Mighty" Strohl

How To Implement the Client-Side DotNetNuke Calendar

There is a handy-dandy little calendar control that DotNetNuke (DNN) uses to insert a date value into a textbox control. However, it is not obvious in its usage. If you look at the source of any of the core modules or admin modules that use the control, you will see the following code in the HTML.

<asp:hyperlink
id="cmdCalendar" resourcekey="Calendar" cssclass="CommandButton"
runat="server">Calendar</asp:hyperlink>

If you look in the code-behind for this, you will notice that there are no events assigned to this control. In order for this control to be used like the core modules do, you need to "invoke" the calendar in the Page_Load event. This "InvokePopupCal" method must be fired every time the module reloads. So, do not put it within a Postback If statement.<

'this needs to always execute so the client script code is registered using InvokePopupCal
cmdCalendar.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtPickUpDate)

The code above actually handles all of the client-side code that will be needed for the calendar to insert the date like you expect it to. Be sure to pay attention to the control that you pass into the "Field" argument (txtPickUpDate above). This is the control that the script will attempt to insert the date into. Although I have not tested this out, I believe that the only control this should work with is a textbox control.



blog comments powered by Disqus