Solved

CalendarExtender On TextChange

Posted on 2009-07-08
2
784 Views
Last Modified: 2012-05-07
I would like to use the AJAX CalendarExtender. Is it possible to attach a C# event which will fire when the date is chaneg.
0
Comment
Question by:Mr_Shaw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
ddayx10 earned 500 total points
ID: 24810375
This isn't exactly what you asked for, but it's as close as I can get'cha :)

Can use client functional of CalendarExtender to send info to postback, and do something from there. See Snippet...
***ASPX PAGE****
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Cal Extender Event</title>
    <script type="text/javascript">
		
		function selectionChanged(sender,args)
		{
			//just about all calendar properties, etc are avail by using
			//sender._[propertyName]
			//If you wanted to send back a more complex argument then I have used
			//Sys.Serialization.JavaScriptSerializer to package them up
			//then de-serialize on the server side :)
			__doPostBack(sender._id,sender._selectedDate);
			
		}
    </script>
</head>
<body>
    <form id="form1" runat="server">
		<asp:ScriptManager ID="sm" runat="server" />
		
		<asp:TextBox ID="txtCal" runat="server" />
		<asp:Button ID="btnCal" runat="server" Text="Show Calendar" />
 
		<cc1:CalendarExtender 
			ID="CalendarExtender1" 
			runat="server"
			TargetControlID="txtCal" 
			PopupButtonID="btnCal"
			OnClientDateSelectionChanged="selectionChanged" />
 
    </form>
</body>
</html>
 
 
****CODE BEHIND****
 
public partial class Default7 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            string eTarget = Request.Params.Get("__EVENTTARGET");
            string eArg = Request.Params.Get("__EVENTARGUMENT");
 
            if (!string.IsNullOrEmpty(eTarget) && !string.IsNullOrEmpty(eArg))
            {
                doStuff(eTarget, eArg);
            }
        }
 
    }
 
 
    private void doStuff(string cTarget, string cArg)
    {
        //do something
    }
}

Open in new window

0
 

Author Closing Comment

by:Mr_Shaw
ID: 31601215
THANKS
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question