Solved

CalendarExtender On TextChange

Posted on 2009-07-08
2
791 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

751 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