Tips for avoiding css reanimation when clicking on a calendar

Recently, I have been experimenting with animating an ASP calendar using CSS and JQuery. My approach involves hiding the calendar initially with CSS and then fading it in when certain events occur. The calendar is contained within an AJAX update panel. However, I encountered a problem when clicking on a specific day in the calendar. The CSS seems to reset, causing the calendar to hide again, and the JQuery animation doesn't trigger as intended. What I'm trying to achieve is to prevent the calendar from hiding when a day is clicked. Despite trying various methods, I have not been successful so far. Here is a snippet of my code:

JavaScript:

$(document).ready(
function ()
{
  ...
  var invoiceB = $(".invoiceBtnPos"); 
  invoiceB.animate({ left: '92%' }, 1500,
        function () {
            var UserCalendarC = $("#UserCalendar");

            UserCalendarC.fadeIn({ duration: 1500 });

            UserCalendarC.classList.remove("DHidden");
        });     
   });

CSS

.DHidden { display:none; }

ASPX

 <asp:UpdatePanel ID="UpdateUserPanel" runat="server">
        <contenttemplate>
            <fieldset class="ZeroDecoration">
             ...
                    <asp:Calendar ID="UserCalendar"  ClientIDMode="Static" runat="server" CssClass="Calendar DHidden" DayNameFormat="Full" ShowGridLines="True" Width="26%" Height="425px" 
                        OnDayRender="UserCalendar_DayRender" NextMonthText="<img src='../Images/nextimg.png' border='0' width='60%' height='auto'>" 
                        PrevMonthText="<img src='../Images/previmg.png' border='0' width='60%' height='auto'>" OnSelectionChanged="UserCalendar_SelectionChanged" >
                        <DayHeaderStyle CssClass="DayHeaderStyle" />
                        <DayStyle CssClass="DayStyle no_underline" ForeColor="White" />
                        <WeekendDayStyle CssClass="WeekendDayStyle no_underline" />
                        <NextPrevStyle CssClass="NextPrevStyle"  />
                        <OtherMonthDayStyle CssClass="OtherMonthDayStyle no_underline" />
                        <SelectedDayStyle CssClass="SelectedDayStyle no_underline" />
                        <SelectorStyle CssClass="SelectorStyle" />
                        <TitleStyle CssClass="TitleStyle" />
                        <TodayDayStyle CssClass="TodayDayStyle no_underline" />
                    </asp:Calendar>  
              ...
            </fieldset>
        </contenttemplate>            
    </asp:UpdatePanel>  

CS

protected void UserCalendar_DayRender(object sender, DayRenderEventArgs e)
{            
    e.Cell.Text += e.Day.DayNumberText;
    e.Cell.ToolTip = e.Day.Date.ToShortDateString();
    e.Cell.Attributes.Add("OnClick",e.SelectUrl);
}

protected void UserCalendar_SelectionChanged(object sender, EventArgs e)
{
   currentDate.Text = UserCalendar.SelectedDate.ToLongDateString();
}

In one of my attempts, I also tried setting the display property in JavaScript at the start, but the resulting behavior was undesirable (showing, then hiding, then fading in)...

window.onload = function ()
{
    var calendar = $("#UserCalendar");

    calendar.css("display", "none");
}

This is my first time seeking help here, so I apologize for any mistakes I might have made.

Answer №1

After posting the question, I quickly realized my mistake and fixed it. The solution was to override the css on Selection changed for the calendar, like this:

    protected void UserCalendar_SelectionChanged(object sender, EventArgs e)
    {
        UserCalendar.CssClass = "Calendar";
        currentDate.Text = UserCalendar.SelectedDate.ToLongDateString();
    }

Although it may not be the most elegant solution, it did the job for me. I appreciate everyone who took the time to help with my question.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Shuffling arrays with JavaScript and jQuery for a touch of randomness

Looking to add some variability to your font choices? I've got an idea for you! How about randomizing three arrays for fonts, font size, and font weight? Then, we can display the results of these arrays in a div with the class name "randomFont." Each ...

Design featuring a combination of vertical columns and a fixed image placed in

I'm currently in the process of creating a website and I have a specific page layout in mind that I would like to implement: ------------------------------------------ | A catchy title | | | Here | An unconve ...

Navigate to the adjacent IDs

I have multiple sections with varying content and links (previous and next) to navigate to the next section. Initially, everything functions properly. However, when adding a new section in between existing ones, I am required to update all the ids to ensu ...

Having trouble with mapping in JSF when using Ajax requests

Within the manager, there is a method that gets called upon blurring of the patientId text field on a JSF page private Patient patientData; //also have get and set public void search(ActionEvent actionEvent){ String aPatientId = (Stri ...

Issues with DataBinding in My ASP.NET User Control

<asp:Repeater ID="repFilter" runat="server"> <HeaderTemplate> <div id="posting" align="center"> </HeaderTemplate> <ItemTemplate& ...

Having trouble making my if / else statement show the_header_image_tag on WordPress

Having some trouble getting my if / else statement to function correctly. I am using a WordPress function called '' and I want to apply different CSS styles based on whether it is used or not. My theme allows for the display of a banner, but onl ...

Can the footer be adjusted to be full width only?

Is there a way to stretch only the footer on a blogger simple template to full width without altering other elements? I have looked into similar topics, but they mainly focus on WordPress or involve changing multiple elements, which is not suitable for my ...

Is it possible to designate a specific font family for italic font style and a different font family for regular font styles in VSCode?

Is it possible to use the "Operator Mono" font only for italic style and another font, such as "Fira Code," for other styles like bold, regular, semibold, etc. in VSCode? I attempted to change the font family to: "editor.fontFamily": "'Operator Mono ...

dynamic progress tracker creation in PHP

I have two web pages. When an ajax call is made from the first page to the second page, it executes PHP code that takes a long time (1-2 minutes). How can I create a progress bar and display the progress percentage in real-time on the first page? I am able ...

Is there a way to ensure that this ajax code functions seamlessly with all types of HTML files?

Currently, I am facing a challenge with an ajax call that retrieves data from a database, which I need to load into an HTML file. The issue lies in the fact that I have various HTML files and I am unaware of their contents. Despite spending countless hour ...

unlocking the full potential of jQuery through dynamic ajax data retrieval

I am struggling with a seemingly easy task and need some help... I am using an ajax call to fetch json data, but I am having trouble manipulating the data once it is received... Despite my efforts, I have been unable to find a solution... This is the co ...

Implementing text overlays on images within a Bootstrap 4 navigation bar

I am struggling to grasp the flex structure in Bootstrap. I'm attempting to overlay text on an image within the navbar, but it seems the container of the navbar is causing issues. Perhaps my containers are not set up correctly. Any assistance would be ...

Deciding on the optimal division of an MVC project

After realizing that my .NET MVC app was becoming difficult to manage, I decided to take action by dividing my project into two parts. Now, all the code is in one part and all the views/content are in the other. However, I am now facing a dilemma: should ...

What methods can I use to achieve a stylish and responsive design for my images?

I have been encountering difficulties styling the images for my website. Despite multiple attempts, I am unable to apply CSS properties such as border-radius and responsive design to the images on my page. The images load fine, but they do not seem to acce ...

The equivalent of the $.curCSS method in jQuery version 1.10 is as follows:

While working with a library called mcdropdown from http://www.givainc.com/labs/, I encountered an issue with the $.curCSS method. The latest version of jQuery no longer supports this method and suggests using $().css instead. Following the documentation, ...

Using Ajax to call a PHP function within a WordPress website

I am looking to trigger a PHP function using AJAX. Below is the code snippet of my form: <form class="woocommerce-form woocommerce-form-login login" method="post"> <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-ro ...

What could be causing my CSS background image to not display properly?

For some reason, I can't figure out why it's just displaying a blank screen. This is what I'm seeing: Here is the structure of my files: The CSS code looks like this: *{ margin: 0; padding: 0; box-sizing: border-box; } html ...

A successful AJAX request in Spring MVC is authenticated

I am facing some issues while trying to send a jQuery AJAX request to my Spring MVC Servlet. I have read several articles, but none of them have been able to help me with my problem :( Here is the AJAX request code snippet in question: $.ajax( ...

Discover the seamless integration of using Angular UI select2 with Angular 1.2.5 for a smooth user

I am attempting to make this jsfiddle compatible with angular 1.2.5 instead of just 1.0.5. http://jsfiddle.net/hWXBv/25/ <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script> The goal is to create a Gmail-lik ...

Issue: The type jQuery does not have a property named context

I am in the process of upgrading jQuery to the latest version, but I have encountered an error that I'm unable to resolve. jQuery is only being utilized in a limited portion of the code, and it cannot be removed at this stage, hence the need for upgra ...