Solved

CalendarExtender On TextChange

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Submit the form at remote server from own server 2 31
Ajax and form.serialize() 4 60
How Do You Create a MVC Modal Popup Using Bootstrap? 1 90
AJAX POST or GET 2 40
There is basically two types of AJAX request in mootools. Request  and Request.HTML Request: Request is the basic XHR request class in MooTools. While not extremely useful on its own, it provides the basic functionality for both Request.HTM…
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, …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now