Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6676455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:59:25+00:00 2026-05-26T03:59:25+00:00

Mine is c# web application. I have a calendar control that defaults to today

  • 0

Mine is c# web application.
I have a calendar control that defaults to today as the selected date.
Problem is, if the user clicks on the selected date then since there is no
change in date the SelectedChanged does not fire. There is no other control
event that fires either. How do I acknowledge the user selection of a
pre-selected date?

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {               
            if (ddlCityNames.SelectedIndex == 0 || ddlHotelNames.SelectedIndex == 0)
            {
                if(ddlCityNames.SelectedIndex==0)
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Select City');", true);   
                else
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Select Hotel');", true);
            }
           }

This is called when user changes his selection.But in case if he selects a date and this validations are called,after that previous selection that he has made is stil there but on click on that selection does nothing.when I select another date and come again on that date is works but what about previously selected date?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:59:25+00:00Added an answer on May 26, 2026 at 3:59 am

    Looking at your code, you will be better off by porting you server side validation logic at the client side. Essentially, you have to hook up into blur event of backing input (of calender control) and validate your drop-downs. This will also eliminate the post-back on the date selection.

    On server side, the validation should be done at the place where all the data will be used – for example, Search button if you are invoking search after hotel, city and date are filled.

    EDIT:

    Here’s some sample code (based on jquery) that should get you started. Instead of Calender control (whose markup I am not familiar with), I am assuming that you are using AJAX Toolkit Calender Extender or some java-script based UI such as jquery date-picker which will be my preference by the way). With both of these approaches, you have full control over backing input field.

    So with AJAX toolkit, markup will be something like

    <asp:TextBox runat="server" ID="Date1" />
    <ajaxToolkit:Calendar runat="server" TargetControlID="Date1" />
    

    Now you can have following script in your markup (aspx) file:

    $(document).ready(function() {
       var date = $('#<%= Date1.ClientID %>');
       var city = $('#<%= ddlCityNames.ClientID %>');
       var hotel = $('#<%= ddlHotelNames.ClientID %>');
    
       date.blur(function() {
         // check if date has been selected
         if (date.val() != '') {
           if (city.val() == '') { // **** put value at index zero that you use for no-selection
              alert('Select City');
           }
           else if (hotel.val() == '') {
              alert('Select Hotel');
           }
         }
       });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that I am hosting, and a client of mine
I have a web application which uses URLs that look like this: http://library.example.com/Register.aspx?query=academic&key=586c70bb-5683-419c-aae9-e596af9ab66a (The
I have a web application with a custom configuration section. That section contains information
I have a web application that I am currently working on that uses a
I have an application that authenticates against a third party web service by sending
I am having a problem with deploying a web application I have developed. It
I have an MVC3 application that is recently published to a web server. This
I have a web application that I'm trying to create a Web Deployment Project
A friend of mine is now building a web application with J2EE and Struts,
We're building tools to mine information from the web. We have several pieces, such

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.