Showing posts with label date. Show all posts
Showing posts with label date. Show all posts

Saturday, March 24, 2012

CalenderExtender and RequiredField Validator

hi all,

I have a problem with ajax. when I select a date from calendarExtender it shows date, but when I submit the form , right before submitting it clears the textbox.

So to get around of this problem I wrote some javascript on button click that sets textBox value to hidden field then I am getting that value from hidden field.

Now problem is that , even if textbox is not empty, it submits the form ( as required) but display requiredField validator error message also. that I don't want.

I mean after successfully processing the request it showing error message.

Hi

Can you give me code that replicates this behavior?

I think I had this issue once but I'm not sure anymore what triggers it.

With some code I might be able to find it!

Kind regards,
Wim


hi,

here goes my source view,

Remind me on</td><td valign="top">
<asp:TextBox ID="remindon" runat="server" ReadOnly="True" Width="89px"></asp:TextBox>
<asp:Image ID="imgCalendar" runat="server" ImageUrl="~/images1/iconCalender.gif" ToolTip="Click to see and hide the calendar" />
<asp:Button ID="btnAddReminder" runat="server" OnClick="btnAddReminder_Click" Text="Add Reminder" ValidationGroup="reminder" Width="103px" OnClientClick="javascript:setReminder();" />

And here is my java-script,

<script type="text/javascript" language="javascript">

function setReminder()
{
document.getElementById("hiddenRemindMeOn").value=document.getElementById("remindon").value;
if(validateDate(document.getElementById("remindon"))==true)
{
return true;
}
else
{
return false;
}
}
function validateDate(obj)
{
var currentTime = new Date();
var currentMonth = currentTime.getMonth() + 1;
var currentDay = currentTime.getDate();
var currentYear =currentTime.getFullYear();

var s=obj.value;
var arr=new Array();
arr=s.split("/");
var selectedMonth=arr[0];
var selectedDay=arr[1];
var selectedYear=arr[2];
//DateValidation selected date should not be less than current date:
if(s!="")
{
if(selectedYear<currentYear)
{
alert("you can not select a date less than today's date");
obj.value="";
return false;
}
else
{
if((selectedMonth<currentMonth) && selectedYear==currentYear )
{
alert("you can not select a date less than today's date");
obj.value="";
return false;
}
else
{
if(selectedDay<currentDay && selectedMonth==currentMonth)
{
alert("you can not select a date less than today's date");
obj.value="";
return false;
}
else
{
return true;
}
}
}
}
else
{
return false;
}
}
</script>

Now how to hide that required field validator error message , while it's processing form successfully....

waiting for reply..

thanks




oh, I had forgot to post required field validator code here,

here it is

<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="remindon"
Display="Dynamic" ErrorMessage="can not be blank" ValidationGroup="reminder"></asp:RequiredFieldValidator>

thanks...


... still waiting for solution.........


Sorry dude I can't work with your code ....

Please provide me with something that I can copy-paste and works!

Kind regards,
Wim


hi,

sorry for incomplete code, here is rest of the calendarExtender code.

rest of code is already given in previous post .

<cc1:calendarextender id="CalendarExtender1" runat="server" cssclass="cal" popupbuttonid="imgCalendar"
targetcontrolid="remindon" EnableViewState="true"> </cc1:calendarextender>

thanks for cooperation


Hi,

No offence but ....

..... still waiting for easy copy-paste code ....

I'm no monkey who takes all your snippets and tries to figure out what goes where, at least take the effort to give me some decent code!

Kind regards,
Wim


Ok I read through this thread again ...

Let's take a few steps back ...

WHAT is your initial goal?

Because by default, the date in the textbox will NOT dissapear!

That's why I asked for YOUR code, and not just some snippets. More like a page that works, AND shows me the wrong behavior.

All the javascript you are adding; writing to hiddenVariable ==> BullShit! This is all obsolete!!!!!!!!!

So please just give me a replication of the code that shows the wrong behavior and lets start from there!

Kind regards,
Wim


I got the problem. my TextBox is read only . when I make it ReagOnly=False , it works fine.

But I have to make it only readonly to force user to select date from calendar only.

Any way Now I am checking for all those at server side. and removed required field validator.

no issue now.......................................................

....thanks u consider my post..........


Hi forums_user,

This thread will answer some questions about why you had that weird behavior:

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

Kind regards,
Wim

calender extender problem

i have a large form that contains about 12 date field. if i place 12 calenders extender the page loading become very slow. is there any way to use only one calender for this 12 field, so this calender appear at the field that the user type in.

Hi

Here a dude says he got a fix for it:http://forums.asp.net/p/1088868/1627224.aspx

You should test it first!

Kind regards,
Wim


thx for your reply

calender Entender

How can get the date with time in a text box using calender Extender

You can get the date from calendar and get the time from DateTime.ShortTime() and concenate them.

Hi bikash,

Go through this Url:http://msdn2.microsoft.com/en-us/library/az4se3k1.aspx

I think u can able to find the solution in this url. Hope this helps.

Thanks & Regards,

Rajak Shaik.


Hi,

Thank you for your post!

Why not go to the official site http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Calendar/Calendar.aspx to check it out?

it show you the sample.

If you have further questions,let me know.

Best Regards,

Calender control in asp.net

Hi, Could anyone please tell me how can i display datepicker when i click textbox or button and i want the date to be in textbox.

could any one give me code to do thhis? i have master page in my project

Thanks for any assistance

Have a look at the ASP.NETAJAX Calendar control.


Hi Tweety,

If you want use CalendarExtender, please download theAjax Control Toolkit. And some pretty samples are contained inside the package.

I hope this help.

Best regards,

Jonathan


Hi. thanks for both of you

im using ajax calender tool kit, jus searchin for good design(i mean css) to apply.

if u have any please suggest me.

thanks again


It really depends on your application as to what style to apply, but if you read thecalender page (specifically the theming section) it will show you how you can customize it to suit your application.


<asp:TextBoxID="TextBox5"runat="server"Width="120px"CssClass="textile"></asp:TextBox></td>

<cc1:CalendarExtenderrunat=serverTargetControlID=textbox5Format="dd/MM/yyyy">

</cc1:CalendarExtender>

im using this code.i have a pblm here once i selected date my date appears in textbox but the calender still can able to see until i clik some where on the page...

why like this?


That's how the control has been built. View thecalendar page for 3 different examples on how it behaves.


Hi Tweety,

If you want to hide the Calendar immediately after we selected a date, you should add thisOnClientDateSelectionChanged="function hideCalendar(cb) { cb.hide(); }" to your source code. OnClientDateSelectionChanged is one property of the CalendarExtendar.

Hope this helps.

Best regards,

Jonathan


Hi thanks but once a date is selected calender hide , but when i reclick the textbox it wont appears...

did i need to quote another javascript here to make calender visible when i click textbox after date selection?


Its fixed...thanks.

http://forums.asp.net/t/1067091.aspx?PageIndex=2

i found my soluntion here..

thanks for everyone.

forums.asp.net ROCKS!!!!

calendarextender: popupbuttonid

I am trying to call a function on my code behind page after a date has been selected from the calendar. I have tried using the popupbuttonid and the click event for that button and I have tried the text box textchanged event. Nothing seems to work. Does any one know how to do this?

Thanks in advance!

Hi dowens,

You should set the property OnClientDateSelectionChanged of the CalendarExtender.

As value, you should give it a function. But the function should be without brackets or an error will occur (not sure why)

Take a look at the following example:

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><%@. Register Assembly="System.Web.Extensions" Namespace="System.Web.UI" TagPrefix="asp" %><%@. 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 id="Head1" runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function test() { alert('test'); } </script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <img id="imgCalendar1" height="20" alt="Change From Date" src="Calendar.png" /> <cc1:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="imgCalendar1" TargetControlID="TextBox1"OnClientDateSelectionChanged="test"> </cc1:CalendarExtender> </div> </form></body></html>
I hope this helps!
Wim

MY BAD .......

The following example call's code behind: (the one in the button's click method on the serverside).

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><%@. Register Assembly="System.Web.Extensions" Namespace="System.Web.UI" TagPrefix="asp" %><%@. 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 id="Head1" runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function test() { var serverButton = document.getElementById('Button1'); serverButton.click(); serverButton = null; } </script> <style type="text/css"> .hide { visibility:hidden; } </style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <img id="imgCalendar1" height="20" alt="Change From Date" src="Calendar.png" /> <cc1:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="imgCalendar1" TargetControlID="TextBox1" OnClientDateSelectionChanged="test"> </cc1:CalendarExtender> <asp:Button ID="Button1" runat="server" Text="Button" CssClass="hide" /> </div> </form></body></html>
Kind regards,
Wim

deblemewim,

I tried your suggestion and it still won't work. Here is the code for the script function and the calendar extender. If you notice the PopupButtonID is the same button that I am trying to call the click event for. I thought this might be the problem so I removed it and it still doesn't work.

function test()
{
var serverButton = document.getElementById('btnEDate');
serverButton.click();
serverButton =null;
}

<cc1:CalendarExtenderID="ceEdate"runat="server"
TargetControlID="txtEDate"
PopupButtonID="btnEDate"
CssClass="MyCalendar"
OnClientDateSelectionChanged="test">
</cc1:CalendarExtender>


Hi dowens,

Well, I don't see your whole code, but I think the your code is not working because your PopupButtonID is a Button (imagebutton, inputbutton, ordinary asp button, ...).

I don't think that is possible!!

When you look at the ajax toolkit examples, they also use either the control (textbox) itself to let the calendar popup, OR they use an image (<img id="myImage" ... ).

So that is the setup you have to go for!!

Is your calendar poping up? Is is that what isn't working?

In my example, I use an image, so the calendar gets poped up. Then, I've set the property OnClientDateSelectionChanged to trigger a javascript function whenever the date changes in the TargetControlID .

When that happens, the javascript locates an ordinary asp:button on the page (which I have hidden), and it triggers it's click event. That way I get code-behind.

If this still doesn't answer your questions, please let me know what exactly you are willing to achieve.

Kind regards,
Wim


Wim,

I think I may have found the issue. The function "test" is not finding the button. Even if I don't hide the button it still doesn't find it. I think the issue may be that I am using a masterpage. I tried your code on a test page and it works fine. The only difference I can find is the master page. I have placed the function in the <head> of the masterpage and I have also tried it on the content page. Neither one works.


Hi dowens,

Sorry for my late reply...

I did some research (since masterpages are quite new to me ...) and I found the following:http://forums.asp.net/t/1031073.aspx (xplaining about how to call javascript from a masterpage).

Now my example should work!

So, on my content page I have the following:

<%@. Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %><%@. Register Assembly="System.Web.Extensions" Namespace="System.Web.UI" TagPrefix="asp" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <script type="text/javascript"> function test() {var serverButton = document.getElementById("<%= Button1.ClientID%>"); serverButton.click(); serverButton = null; } </script> <br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <img id="imgCalendar1" height="20" alt="Change From Date" src="Calendar.png" /> <cc1:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="imgCalendar1" TargetControlID="TextBox1" OnClientDateSelectionChanged="test"> </cc1:CalendarExtender> <asp:Button ID="Button1" runat="server" Text="Button" CssClass="hide" /></asp:Content>

The script is now in the content page, but I guess it should also be possible to place it somewhere else or just use a link to it (haven't tested that ..)

Hope this helps!
Wim


Wim,

It works great!! Thanks for your help.

Dale

CalendarExtender: close on client selectes date?

Hi,

just wondering how to make the calendar close when a date is selected...

<

asp:Tablerunat="server"ID="CalendarTable"HorizontalAlign="Center"Width="100%"Height="100%"BackColor="LightGray"><asp:TableRow><asp:TableCellVerticalAlign="Top"><asp:Labelrunat="server"ID="fromDateLabel"Text="from:"CssClass="label"></asp:Label><asp:TextBoxrunat="server"ID="fromTB"CssClass="normal"></asp:TextBox><ajaxToolkit:CalendarExtenderrunat="server"ID="fromCalendar"TargetControlID="fromTB"CssClass="MyCalendar"Animated="true"></ajaxToolkit:CalendarExtender><br/></asp:TableCell><asp:TableCellVerticalAlign="Top"><asp:Labelrunat="server"ID="toDateLabel"Text="to:"CssClass="label"></asp:Label><asp:TextBoxrunat="server"ID="toTB"CssClass="normal"></asp:TextBox><ajaxToolkit:CalendarExtenderrunat="server"ID="toCalendar"TargetControlID="toTB"CssClass="MyCalendar"Animated="true"></ajaxToolkit:CalendarExtender></asp:TableCell><asp:TableCell><asp:Buttonrunat="server"ID="calendarQueryButton"CssClass="button"Text="Search"/></asp:TableCell></asp:TableRow></asp:Table>

I solved this problem by putting

PopupButtonID property to the same textBox


dark_angle:

I solved this problem by putting

PopupButtonID property to the same textBox

I had that. Removed it to solve another issue: with that property set as well, clicking anywhere else on the screen did not dismiss the calendar. And clicking on the second TextBox made a 2nd calendar without dismissing the first...

CalendarExtender: Anyway to AutoPostBack?

I'd like to cause a post back when a user selects a date using the CalendarExtender. Anyway to do this?

You could try this...

1) Add the following code to your page's OnLoad event - this basically registers a function to handle the calendar date selection change on the client and force a postback (sorry if you're a C# person)

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadConst strKeyAs String ="calendarExtenderPostback"If Not Me.ClientScript.IsClientScriptBlockRegistered(Me.GetType(), strKey)Then Dim pboAs PostBackOptions =New PostBackOptions(Me) pbo.AutoPostBack =True pbo.RequiresJavaScriptProtocol =False pbo.PerformValidation =True Dim strScriptAs String =String.Format("function calendarExtenderPostback(e) {{ {0} }}",Me.ClientScript.GetPostBackEventReference(pbo).ToString)Me.ClientScript.RegisterClientScriptBlock(Me.GetType(), strKey, strScript,True)End If End Sub

2) Add the following markup to your page to create the script manager, textbox and calendar extender... NB the use of OnClientDateSelectionChanged

<asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager>

<asp:TextBoxID="DateTextBox"runat="server"/>

<ajaxToolkit:CalendarExtenderID="CalendarExtender1"runat="server"TargetControlID="DateTextBox"Format="dd MMM yyyy"OnClientDateSelectionChanged="calendarExtenderPostback"/>


This works...to a point. It causes a postback, but not one that UpdatePanels seem to recognize. When I cause a postback using a button the content on my page in updatepanel's correctly updates. When I use the CalendarExtender autopostback method you described, the whole page refreshes. Any ideas?


There are quite a few posts on these forums for forcing an UpdatePanel to postback... it doesn't look like there currently a "correct" method of doing this (e.g. UpdatePanel.Update()) - though I might be wrong...

Suggestions include having a hidden button (using style="display: none") in your UpdatePanel which triggers the update.

You can then force the Click event for this in the code I described above (instead of the postback code)... which will in turn force the UpdatePanel to update!

This post may help...http://forums.asp.net/thread/1426873.aspx

Hope this makes sense!

Wednesday, March 21, 2012

CalendarExtender: 2007-05-2 is a wrong date

I am not sure how big of a problem this is but here I got this response from of our customers endusers regarding the CalendarExtender.
Her "errorreport" suggested that the control failed to return the wrong dateformat. The format for today would be 2007-05-2 (swedish locale) which IRL looks unnatural because we write it as 2007-05-02 normally. Even though the dates are exactly identical it still causes confusion.

Any idea on how to fix this?

Hi,

try using to set the Format property of the Calendar Extender which would probably be in your case something like yyyy-MM-dd. Also take a look at this post:EnableGlobalization property on the ScriptManager.

Grz, Kris.


EnableScriptGlobalization="true" alraeady was set on the ScriptManager. However the formatstring was yyyy-MM-d, when I changed it to yyyy-MM-dd it worked.

CalendarExtender....

Hello, Everyone

Please can you help me out with this in (VB)...?

I have a form with a calendarExtendar. When I select a date, and a postback happens I lose the selected date value.

Also when I try and insert I get the todays value and not the selected one..

You have any suggestions?

After deleting everything and starting again it works ….very strange


The problem was not solved by deleting everything…. But it help me find out where the problem actually is! The problem lies with the image pop up for the calendar control …. Delete that and you will stop getting the current date after postback… If you know the solution is let me know…


Post some code...though the post back problem sounds more like you have forgotten to put the load methods inside an "If(!Page.IsPostBack)" block.

Ignore


As requested.... Please can you explain further or suggest some reading about "load methods inside an "If(!Page.IsPostBack)"

ProtectedSub SqlDataSource1_Inserting(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
Dim Textbox22As TextBox = FormView1.FindControl("TextBox22")

Dim Textbox1As TextBox = FormView1.FindControl("TextBox1")

Dim sDateTimeAsString =CStr(Textbox22.Text) +" " +CStr(Textbox1.Text)Dim OpenDateTimeAsDate = DateTime.Parse(sDateTime)

e.Command.Parameters("@.OpenDateTime").Value = OpenDateTime

EndSub

<tr>

<tdnowrap="nowrap"style="width: 235px">

System Target Date of Resolution</td>

<tdstyle="width: 390px">

<asp:TextBoxID="TextBox22"runat="server"Style="position: static"</asp:TextBox>

<asp:Imagerunat="Server"ID="Image2"ImageUrl="~/images/Calendar_scheduleHS.png"/>

<asp:RequiredFieldValidatorID="RequiredFieldValidator8"runat="server"ControlToValidate="TextBox22"

ErrorMessage="Select Target date"Style="position: static"InitialValue="Select Date">*</asp:RequiredFieldValidator>

<cc1:CalendarExtenderID="CalendarExtender2"runat="server"

TargetControlID="textbox22"

PopupButtonID="Image2"Format="dd MMM yyyy"CssClass="Calendar">

</cc1:CalendarExtender>

</td>

</tr>

<tr>

<tdnowrap="nowrap"style="width: 235px; height: 21px">

System Target Time of Resolution</td>

<tdstyle="width: 390px; height: 21px">

<asp:TextBoxID="TextBox1"runat="server"Style="position: static" </asp:TextBox>

<asp:RequiredFieldValidatorID="RequiredFieldValidator9"runat="server"ControlToValidate="TextBox1"

ErrorMessage="Select Target Date"Style="position: static"InitialValue="Enter Time HH:MM">*</asp:RequiredFieldValidator></td>

<cc1:MaskedEditExtenderID="MaskedEditExtender3"

runat="server"

TargetcontrolID="TextBox1"

Mask="99:99"

Masktype=Time

MessageValidatortip=True

AcceptAMPM=False

/>

</tr>

CalendarExtender, want only current month date visible

hi all,

I have a problem, I want to display days of only current month or whichever month a user selects. I mean by default calendar extender shows all dates , even if we have selected November, it will show some days of previous month and some days of next month along with current month's dates. I only want to display current month's dates.

I applied css specified in http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Calendar/Calendar.aspx

but that's changing color of each day. I was thinking by using css somehow i will hide previous and next month days, but of not avail.

please suggest,

thanks...

Hi Forums_user,

As far as I know, it is not supported now unless you modify its source code. CalendarExtender generate all the days , months and years on the client, you can find it in its source code with the name _buildDays,_buildMonths and _buildYears.

I hope this help

Best regards,

Jonathan

CalendarExtender, MaskedEditExtender, and MaskedEditValidator

Hi all,

I have this fiddly situation where I have a MaskedEditExtender to give me a date mask on a TextBox, and a MaskedEditValidator to give the user feedback if the date is invalid - empty is allowed. I also have a CalendarExtender on this TextBox so the user doesn't have to type. I have two things to note:

    When you set "ClearMaskOnLostFocus" of the extended TextBox properties, the CalendarExtender doesn't work - you can set the date, but when you click away to hide the calendar, it also resets the mask and the TextBox content.When you do not have "ClearMaskOnFocus" set, allow empty values, click in the TextBox (to bring up the input mask), and click out again - the input mask remains and any validation message you attached to the MaskedEditValidator now appears - this goes against what I expect to be correct, as the TextBox is empty.

The third problem that I won't number is that the two problems are exacerbated by the CalendarExtender, without that only the second problem would persist, which could furthermore be solved by setting "ClearMaskOnLostFocus". I haven't tested what happens to the TextBox and its values etc in any other situation.

Has anyone else encountered this issue?

Temporarily, does anyone have a work around? I require the calendar object to give the user a mouse option, and need a basic input mask toat leastblock out alphabetic characters and format the date in dd/MM/yyyy format.

Thanks in advance!

Hello. Might be a bit late for an reply, but I had the same problem as you. I was using a textBox with a MaskedEdit & a CalendarExtender.

I was clicking on the textbox, the calendar was showing up. One time on two, it was telling me the date was invalid (but it was valid). And the weirdest thing was when I clicked on a date, it was writing it in the textbox, saying it was valid. But as soon as I clicked outside the calendar to close it, the validator was emptying the textbox and telling me it was an invalid date.

I was losing it, but strangely, when I read your post I decided to try adding a "ClearMaskOnLostFocus="False" (that parameter wasn't originally declared so I don't know what is the default value). and now ... it WORKS 100%.

Btw, I'm using DD/MM/YYYY format. The easiest trick to do that is simply to set the MaskedEditExtender's culture to "en-GB" and it worked #1. Here's my code of a working textbox with a calendar, all using the DD/MM/YYYY format.

<asp:LabelID="Label5"runat="server"Font-Bold="True"Font-Size="Smaller"Style="text-align: right"

Text="DATE DéPART:"Width="143px"></asp:Label>

<asp:TextBoxValidationGroup="dateValidator1"MaxLength="1"ID="dateDepart"runat="server"style="text-align:center"Width="77px"></asp:TextBox>

<asp:LabelID="Label14"runat="server"Width="68px"></asp:Label>

<cc1:MaskedEditValidatorID="MaskedEditValidator1"runat="server"

ControlExtender="MaskedEditExtender1"

SetFocusOnError="true"

Display="Dynamic"

ControlToValidate="dateDepart"

IsValidEmpty="False"

EmptyValueMessage="Date is required"

InvalidValueMessage="Date is invalid"

ValidationGroup="dateValidator1"

TooltipMessage="Input a Date"/>

<asp:LabelID="Label7"runat="server"Width="75px"></asp:Label><br/>

<cc1:CalendarExtenderID="CalendarExtender1"runat="server"Format="dd/MM/yyyy"TargetControlID="dateDepart">

</cc1:CalendarExtender>

<br/>

<br/>

<cc1:MaskedEditExtenderID="MaskedEditExtender1"runat="server"

MaskType="Date"

TargetControlID="dateDepart"

Mask="99/99/9999"

CultureName="en-GB"

MessageValidatorTip="true"

OnFocusCssClass="MaskedEditFocus"

OnInvalidCssClass="MaskedEditError"

ClearMaskOnLostFocus="false"

DisplayMoney="Left"

AcceptNegative="Left"/>

<br/>

Pat.


I ran into some of the same problems. My issue was allowing for empty values w/out invalidating. Seethis post for more info and sample code.

Hope this helps.

CalendarExtender, MaskedEditExtender, and MaskedEditValidator

Hi all,

I have this fiddly situation where I have a MaskedEditExtender to give me a date mask on a TextBox, and a MaskedEditValidator to give the user feedback if the date is invalid - empty is allowed. I also have a CalendarExtender on this TextBox so the user doesn't have to type. I have two things to note:

    When you set "ClearMaskOnLostFocus" of the extended TextBox properties, the CalendarExtender doesn't work - you can set the date, but when you click away to hide the calendar, it also resets the mask and the TextBox content.When you do not have "ClearMaskOnFocus" set, allow empty values, click in the TextBox (to bring up the input mask), and click out again - the input mask remains and any validation message you attached to the MaskedEditValidator now appears - this goes against what I expect to be correct, as the TextBox is empty.

The third problem that I won't number is that the two problems are exacerbated by the CalendarExtender, without that only the second problem would persist, which could furthermore be solved by setting "ClearMaskOnLostFocus". I haven't tested what happens to the TextBox and its values etc in any other situation.

Has anyone else encountered this issue?

Temporarily, does anyone have a work around? I require the calendar object to give the user a mouse option, and need a basic input mask toat leastblock out alphabetic characters and format the date in dd/MM/yyyy format.

Thanks in advance!

Apologies, I appear to have double posted - use the other one :)

CalendarExtender with Minimum and Maximum Date that can be selected???

I have Textbox with CalendarExtender and RangeValidator for it..But I need that Minimum value for RangeValidator to be selected is Today(DateTime.Now) and Maximum value to be 1/01/2009 .How to do it,can someone write code for it...I tried but I always get some errors..ControlExtender Format is set to this ="d/MM/yyyy"

Page Load

rangevalidator1.minimumvalue = DateTime.Now.ToShortDateString

rangevalidator1.maximumvalue = "1/01/2009"

Here is the answer...and it works perfectly...

Code behing

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

RangeValidator1.MinimumValue = DateTime.Now.ToString("dd-MM-yyyy")

RangeValidator1.MaximumValue ="30-12-2200"

EndSub

<formid="form1"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<ajaxToolkit:CalendarExtenderID="CalendarExtender1"runat="server"TargetControlID="TextBox1"Format="dd-MM-yyyy">

</ajaxToolkit:CalendarExtender>

<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>

<asp:RangeValidatorID="RangeValidator1"runat="server"ErrorMessage="RangeValidator"ControlToValidate="TextBox1"Type="Date"></asp:RangeValidator>

</form>

CalendarExtender with ImageButton problem........

In this application,when you press the ImageButton ,the calenda will show; when you press the ImageButton again or select a date ,the calenda will disappear..

But what I wanna realize is that ,when you click the rest of the page ,the calenda will also disappear, how to realize that??

Thank you very much!!!!!!!!!

Default.aspx

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<link href="http://links.10026.com/?link=StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<br /><br />
<b>Calendar with associated button:</b><br />
<asp:TextBox ID="Date3" runat="server"></asp:TextBox>
<asp:Image ID="Image1" runat="server" ImageUrl="~/Calendar_scheduleHS.png" />
<ajaxToolkit:CalendarExtender ID="CalendarExtender3" runat="server" TargetControlID="Date3" PopupButtonID="Image1">
</ajaxToolkit:CalendarExtender>

</form>
</body>
</html>

Hi liuyan,

This is an issue of the Ajax Control Toolkit that is known for a while now.

It is even something that will be fixed in an upcoming release of the Toolkit.

You should check the website. This is a direct link to the Issue you talk about.http://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=7571

Look at the comments on that site: They include a workaround for this issue until it is fixed in the upcoming release.

Hope this helps!
Kind regards,
Wim


Hi liuyan,

For you situation, I think the easiest way is when hide the Calendar manually when OnClientDateSelectionChanged event occurs. Here is the sample you can refer to:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1"
Format="yyyy-MM-dd" PopupButtonID="Button1"OnClientDateSelectionChanged="function hideCalendar(calendar) { calendar.hide(); }">
</ajaxToolkit:CalendarExtender>
<asp:Button ID="Button1" runat="server" Text="Calendar" />

I hope this help

Best regards,

Jonathan

CalendarExtender to fill 2 date text boxes

Anybody know of a way for a single CalendarExtender to fill 2 text boxes?

I would like a single calendar to fill both a start and end date. Because the TargetControlID only takes one parameter, I'm not sure how to do this.

Spent some time on google trying to find a solution but came up empty.

Thank you.

I came up with this simple solution.

In Page_Load

If Page.IsPostBack =FalseThen

Me.txtStartDate.Attributes.Add("onchange","FillEndDate()")

End if

<scripttype="text/javascript"language="javascript">

function FillEndDate(){

document.aspnetForm.ctl00_ContentPlaceHolder1_txtEndDate.value = document.aspnetForm.ctl00_ContentPlaceHolder1_txtStartDate.value

}

</script>

CalendarExtender returns date in wrong format

Hi, i'm using the CalendarExtender control within my web forms. However it keeps returning my dates in the format mm/dd/yyyy but i need it in the format dd/mm/yyyy. I was wondering if someone could tell me how this could be done. ThanksUse the Format property of the CalendarExtender.

CalendarExtender reads textbox as MM/dd/yyyy regardless of Format field.

Regardless of what I set the Format field to the CalendarExtender always reads the date from the textbox in american MM/dd/yyyy format.

My site is in NZ format dd/MM/yyyy.

Anyone know a workaround?

The problem is with the date parsing, in that I'm only currently doing new Date(dateString), which does not obey the format rules specified yet. There is no format-specific date parsing in javascript or in the AJAX core, so I will have to talk with the team to determine how best to handle this.

Picker has some more complicated parsing features I may generalize to support this, so keep an eye on the project progress while we attempt to resolvethis.


Thank you for your help. Is there any way I can work around the problem by manually altering the date the calendarextender at some event?


Hi,

I have just tested it basing on AJAX 1.0 and it works for me if I set format like dd-MM-yy and properly fill in the master text box.

Double check please if you master text box has AutoPostBack set to false.

Regards,

Adam Koszlajda

CalendarExtender question

How do I get the CalendarExtender to close when a date is selected. I tried below, but when I click a date, the textbox is populated, but the calendar is still displayed.

<asp:TextBoxID="TextboxEnd"runat="server"Text="enter end date"/>

<ajaxToolkit:CalendarExtenderID="CalendarExtenderEnd"runat="server"TargetControlID="TextBoxEnd"Animated=true/>

That's funky...we had the opposite problem: if you brought up the calendar but didn't want to select a date...just make it disappear...and clicked anywhere else on the screen, it wouldn't hide the calander until you selected a date.

We found that the new version of the Toolbox that was released recently fixes our issue...it might fix yours too...are you using the updated Toolbox controls or the older ones?

Just curious: does this happen in Firefox and IE, or just in one?


It happens in both IE and FF. I think I am using the new ones. I downloaded about a month ago. Was there a new build since then? The only way I can get the calendar to disappear is to click somewhere else on the screen.


Thanks, D'Arcy. I downloaded the September 2007 release and it's working great now.

CalendarExtender Question

I was wonering if there is a way to fire a javaScript function after the user selects a date. Kind of like in the ModelPopup where we can set the onOkScript property except this would be like an OnDateChangedScript property...is there an easy way to do this with the CalendarExtender? Basically the date would already be updated on the screen and I want to call this javaScript function to send the new date back to the data base via JavaScript/WebService...Any thoughts?

Thanks, Greg

That is what the onClientDateSelectionChanged method is for!!...nevermind.

I have an example as to how to fire a javaScript event after the user select a different date...you can see the code here:http://forums.asp.net/thread/1627224.aspx

CalendarExtender onclick?

When you click on a date in the ajaxToolkit's Calendar Extender, the calendar doesn't disappear. What can I do so that it disappears on clicking a date?

to close the calendar onClick i set this up in the code behind

//Hide the calendarprotected override void OnLoad(EventArgs e) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"hideCalendar", @."function hideCalendar(cb) { cb.hide(); }",true);base.OnLoad(e); }

and this is what the asp code looks like

 <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate" OnClientDateSelectionChanged='hideCalendar'>

Great, I had the same issue.

Actually I noticed that you don't need to have any code behind, you can simply put:

OnClientDateSelectionChanged="function hideCalendar(cb) { cb.hide(); }"

And it will work. Works even if you have more than one extender.


Thanks a lot guys! You saved a life today!


Hello..!

Is there anyone who can help me...! Please. I have created a web page with master page then i inserted CalendarExtender in the web page but in running mode when i click on the related textbox it doesnt show the calendar... I dont know why?...
note: i inserted script manager in master page......

So, What is the possible solution..???

Thanks, Waseem


I just had problems with the calendar extender myself so I think i can help... but u'll have to show us what you have already!