Solved

CalendarExtender On TextChange

Posted on 2009-07-08
2
773 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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 …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 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