Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 819
  • Last Modified:

CalendarExtender On TextChange

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
Mr_Shaw
Asked:
Mr_Shaw
1 Solution
 
ddayx10Commented:
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
 
Mr_ShawAuthor Commented:
THANKS
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now