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

Discussion in 'ASP .Net' started by mark4asp, Mar 8, 2007.

  1. mark4asp

    mark4asp Guest

    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);
    }
    }
    }
    mark4asp, Mar 8, 2007
    #1
    1. Advertising

  2. mark4asp

    Mark Rae Guest

    "mark4asp" <> wrote in message
    news:...

    > * should I look for a pure javascript date picker?


    That's certainly my preferred option...
    Mark Rae, Mar 8, 2007
    #2
    1. Advertising

  3. mark4asp

    mark4asp Guest

    On 8 Mar, 14:59, "Mark Rae" <> wrote:
    > "mark4asp" <> wrote in message
    >
    > news:...
    >
    > > * 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.
    mark4asp, Mar 8, 2007
    #3
  4. mark4asp

    Mark Rae Guest

    "mark4asp" <> wrote in message
    news:...

    >> > * 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...
    Mark Rae, Mar 8, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ahmet Gunes
    Replies:
    1
    Views:
    1,657
    Norman Yuan
    Jun 19, 2005
  2. =?Utf-8?B?UmFqYW5p?=

    stop firing validation controls

    =?Utf-8?B?UmFqYW5p?=, Apr 25, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    468
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Apr 25, 2006
  3. Randy

    Events fire and then stop firing

    Randy, Dec 6, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    339
    Randy
    Dec 6, 2006
  4. SevDer
    Replies:
    2
    Views:
    1,300
    Walter Wang [MSFT]
    Nov 13, 2007
  5. Rajani

    Stop firing validation controls

    Rajani, Apr 25, 2006, in forum: ASP General
    Replies:
    1
    Views:
    98
    Mike Brind
    Apr 25, 2006
Loading...

Share This Page