C# .NET - get the data of a ajaxToolkit:CalendarExtender

Asked By Kin Regtur on 21-Jan-09 11:22 AM
Hello All,

How can I get the data of a ajaxToolkit:CalendarExtender?

My code dosn't work.



Regards
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calendar.aspx.cs" Inherits="Calendar" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> 
<!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>Untitled Page</title>
    <link href="../css/styles/ajax__calendar.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
            <asp:TextBox ID="txtDate" runat="server" Width="70"></asp:TextBox>
            <ajaxToolkit:CalendarExtender 
                ID="ceCalendar" 
                runat="server"
                PopupButtonID="ibtnCalendar"
                TargetControlID="txtDate">
            </ajaxToolkit:CalendarExtender> 
            <asp:ImageButton ID="ibtnCalendar" ImageUrl="http://farm3.static.flickr.com/2377/2293253497_ee669aca61.jpg?v=0" Width="20px" runat="server" />
            <asp:Literal ID="Literal1" runat="server"></asp:Literal>
            <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>
</html>
----------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Calendar : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Literal1.Text = txtDate.Text.ToString();
    }
}

try this

ram kumar replied to Kin Regtur on 21-Jan-09 11:43 AM

Hi.

<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
<ajaxToolkit:MaskedEditExtender
ID="maskExtDate" runat="server"
TargetControlID="txtDate"
Mask="99/99/9999"
Century="2000"
CultureName="en-gb"
MessageValidatorTip="true"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="Date"
DisplayMoney="None"
AcceptNegative="None"
ErrorTooltipEnabled="True" />
<ajaxToolkit:MaskedEditValidator
ID="maskVldDate" runat="server"
ControlExtender="maskExtDate"
ControlToValidate="txtDate"
EmptyValueMessage="Date is required"
InvalidValueMessage="Date is invalid"
Display="Dynamic"
TooltipMessage="Input a date"
EmptyValueBlurredText="*"
InvalidValueBlurredMessage="*" ></ajaxToolkit:MaskedEditValidator>
<ajaxToolkit:CalendarExtender
ID="calDate" runat="server"
BehaviorID="calDateBehaviour"
TargetControlID="txtDate"
CssClass="PieCalendar" Format="dd/MM/yyyy" />
<script type="text/javascript">
function TextDateChanged(newDate)
{
try
{
var d = Date.parse(newDate);
$find("calDateBehaviour").set_selectedDate = d;
}
catch (Exception)
{
}
}
</script>

        protected void Page_Load(object sender, EventArgs e)
{
txtDate.Attributes["onchange"] = "TextDateChanged(this.value)";
}

read this

C_A P replied to Kin Regtur on 22-Jan-09 03:59 AM
This is because you have set the textbox's read only property to true. If you remove that property, textbox.Text will get you the date selected by the calendar control.

TRY THIS LINK

C_A P replied to Kin Regtur on 22-Jan-09 04:00 AM

http://www.codeverge.net/item.aspx?item=407123

http://forums.asp.net/t/1073184.aspx

http://www.builderau.com.au/program/dotnet/soa/Enhance-applications-with-the-ASP-NET-AJAX-Control-Toolkit/0,339028399,339283620,00.htm

 

Adriann Louie Marquez replied to Kin Regtur on 16-Aug-10 04:24 AM
Instead of using ASP.NET's ScriptManager, you should instead use AjaxControlToolkit's ToolkitScriptManager. If you don't do this, you would also have a buggy RoundedCornersExtender.

So, instead of doing this:

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Write this one:

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ScriptManager>
For more tips and tricks in ASP.NET and .NET, check this out:

http://stixbreakstonez.weebly.com/