By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,489 Members | 1,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,489 IT Pros & Developers. It's quick & easy.

How can I stop my Calendar control from firing the form validation events?

P: n/a
How can I stop my Calendar control from firing the form validation
events?

I have a form containing several controls which have several
validation controls each.

One control is a TextBox where the date is entered. Connected to this
is an image button which launches a popup window containing a calendar
control. The selected value from the calendar is then fed back to the
TextBox.

<asp:TextBox ID="txtDate" runat="server" CausesValidation="true" />
<input ID="lnkDatePopUp" class="imgCalendar" type="image"
onclick="window.open('DatePopUp.aspx?
FormItemName=ctl00$ContentPlaceHolder
$txtDate','cal','width=250,height=225,left=270,top =180')"
Width="100px">

When this happens, the validation warnings are shown for controls
without values. How can I stop this?

For instance:
* can that be done with AJAX?
* should I look for a pure javascript date picker?
* is there are way to achieve my objective by putting the Calendar
control on the same page? (inside a DIV)
The server code for the popup page is shown below:

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 Administration_DatePopUp : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
hid.Value =
((string)Request.QueryString["FormItemName"]).ToString();
}
protected void Calendar1_SelectionChanged(object sender, EventArgs
e)
{
// Define the name and type of the client scripts on the page.
String csname2 = "CalSelectionChange";
Type cstype = this.GetType();

// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;

// Check to see if the client script is already registered.
if (!cs.IsClientScriptBlockRegistered(cstype, csname2))
{
string strScript = "<script>window.opener.document.forms(0)." +
hid.Value + ".value = '" +
Calendar1.SelectedDate.ToString("dd/MM/yyyy") +
"';self.close();</script>";
cs.RegisterClientScriptBlock(cstype, csname2, strScript, false);
}
}
}

Mar 8 '07 #1
Share this Question
Share on Google+
3 Replies

P: n/a
"mark4asp" <ma******@gmail.comwrote in message
news:11**********************@8g2000cwh.googlegrou ps.com...
* should I look for a pure javascript date picker?
That's certainly my preferred option...
Mar 8 '07 #2

P: n/a
On 8 Mar, 14:59, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"mark4asp" <mark4...@gmail.comwrote in message

news:11**********************@8g2000cwh.googlegrou ps.com...
* should I look for a pure javascript date picker?

That's certainly my preferred option...
Mark - there's a new AJAX control which looks very swanky to me:

<http://ajax.asp.net/ajaxtoolkit/Calendar/Calendar.aspx>

I will have to use that one - I can't imagine a javascript control
being anything like as nice as that!

I downloaded that same toolkit weeks ago - so the new calendar
must'vwe apeared after 20 Feb 2007.
Mar 8 '07 #3

P: n/a
"mark4asp" <ma******@gmail.comwrote in message
news:11*********************@p10g2000cwp.googlegro ups.com...
* should I look for a pure javascript date picker?

That's certainly my preferred option...

Mark - there's a new AJAX control which looks very swanky to me:
Yes indeed...
I will have to use that one - I can't imagine a javascript control
being anything like as nice as that!
You'd be surprised...

Don't forget that every scroll and click fires a round-trip to the server
and back - a callback is (usually) much less costly than a postback, and
doesn't redraw the entire page obviously, but it's still a hit on the server
which, if you can avoid it, is almost always a good thing to do...
Mar 8 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.