Getting AJAX Calendar to work with visual studio


I am trying to use AJAX with my cSharp lab. I have downloaded all the AJAX stuff necessary and have created an AJAX enabled website. Right now I am trying to get the calendar to work and I am receiving the following error:

The TargetControlID of 'CalendarExtender1' is not valid. The value cannot be null or empty.

I will be asking a whole lot of questions for a while this is like question 1 out of 100.

Here is my code below.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddUser.aspx.cs" Inherits="AddUser" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="Ajax" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <h1>Sign up to NAITBook</h1>
    <form id="Form1" method="post" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <tr><td>First Name:</td>
                <td><asp:TextBox Runat="server" ID="txtUsername" /></td></tr>
            <tr><td>Last Name:</td>
                <td><asp:TextBox Runat="server" ID="TextBox1" /></td></tr>   
                <asp:DropDownList ID="ddlGender" runat="server">
            <tr><td>Date of Birth:</td>   
                <Ajax:CalendarExtender ID="CalendarExtender1" runat="server">
                <td><asp:TextBox Runat="server" ID="txtPassword" TextMode="Password"  /></td></tr>
            <tr><td><asp:Button ID="btnSumbit" runat="server" Text="Sumbit" /></td></tr>
    <div style='color:red'>
        <asp:Literal Runat="server" ID="lblMessage" />

Open in new window

Who is Participating?
mrcoolcoderConnect With a Mentor Commented:
Look at tip #6, you will have to override the calculation using JavaScript
The Calender extender needs a textbox to hold the date value, so you need to add a date textbox.  Lets call it "DOBTextbox" and then you need to add "TargetControlID = 'DOBTextbox'  ".  Once you do that, your textbox will now be associated with the Calender extender.  

Don't forget your script manager at the top of the page.
tqrecordsAuthor Commented:
cool, is there also a way to make the default go to the year selection when you click on it??
Try this:

If needed, you could actually change some of the controls JavaScript but I have not had the pleasure of doing that.
tqrecordsAuthor Commented:
hmm its a little more complicated than I thought.

Never mind that. Would you know how to take the date of birth selected from the calender then change that to their age and put the integer value in the textbox?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.