Modify the date label according to user preference

I am currently working with C#.net to develop a reservation system

My goal is to provide the user with the option to change the date using arrows, similar to the image displayed (please click on the link)

Date Image

https://i.sstatic.net/sBP5r.png

I have successfully implemented displaying the current date on the screen, but I am unsure of how to enable the user to use arrows to adjust the dates. Below are the HTML codes:

<asp:Label ID="lblServerDateTime" runat="server" CssClass="auto-style13" style="font-size:30px;" />

As well as the C# code snippet:

protected void page_load(object sender, EventArgs e)
{
    lblServerDateTime.Text = DateTime.Now.ToString("M");
}

Answer №1

Here are some helpful snippets for you:

HTML

 <asp:Button Text="Download" ID="btnDownload" runat="server" OnClick="btnDownload_Click" />
 <asp:Label ID="lblServerTime" runat="server" CssClass="auto-style13" Style="font-size: 30px;" />
 <asp:Button Text="Upload" ID="btnUpload" runat="server" OnClick="btnUpload_Click" />

Backend Code

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lblServerTime.Text = DateTime.Now.ToString("dd MMMM");
            calCurrentDay.SelectedDate = DateTime.Now;
            // Sets current date initially.
        }
    }

protected void btnUpload_Click(object sender, EventArgs e)
    {
        //Upload button click will increase the date by one day
        DateTime.TryParse(lblServerTime.Text, out d);
        d = d.AddDays(1);
        lblServerTime.Text = d.ToString("dd MMMM");
        calCurrentDay.SelectedDate = d;
    }

protected void btnDownload_Click(object sender, EventArgs e)
    {
        //Download button click will decrease the date by one day
        DateTime d;
        DateTime.TryParse(lblServerTime.Text, out d);
        d = d.AddDays(-1);
        lblServerTime.Text = d.ToString("dd MMMM");
        calCurrentDay.SelectedDate = d;
    }

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

Enhance video playback by eliminating accidental scrolling through the space bar

When using a video player, I always prefer to pause it by pressing the spacebar. However, this function is not working as expected. The issue at hand is that instead of pausing the video, pressing the space bar causes the page to scroll down unexpectedly ...

Switching Browser from IE to Firefox: A Step-by-Step Guide

Currently, I am developing a C# .NET application utilizing System.Windows.Forms.WebBrowser. Encountering issues with IE not responding as expected has prompted me to consider switching to Mozilla Firefox. What steps should I take to make this transition ...

Exploring a deep Nested JSON Structure and appending a new attribute

Dealing with a JSON input that can have an undefined number of levels, I am looking to add a specific attribute at all levels. [{ title:' ' , id : ' ', description: ' ', date :' ', children:[{ childre ...

Using a button click event within a repeater control to display information within the same repeater in ASP.NET using C#

I am trying to implement a functionality where clicking on a specific button inside a repeater will only make the corresponding textbox visible for user input. However, my current implementation is causing all textboxes to become visible when any button is ...

What is the proper way to utilize document.getElementById() within a standalone js file?

As I dive into learning web development for the first time, I've decided to keep my scripts organized in separate files. However, I'm facing a challenge when trying to access elements from these external files. Below is a snippet of the JavaScri ...

What methods can be used to analyze MSIL code in order to locate specific function invocations?

I'm currently working on developing a GUI framework for SOA and my goal is to automatically detect services and their dependencies from client modules. I have already implemented code using attributes on class modules like this: [ServiceProvider(type ...

Angular JS - Establishing a Connection to Woocommerce OAuth v1

I'm having trouble authenticating myself with the rest service. I attempted to use this library to generate all the necessary parameters as mentioned here, and I constructed the request like this: $scope.oauth = new OAuth({ consumer: { p ...

The rendering of code is often disrupted when utilizing the keyword const

I've been working my way through the Angular2 tutorial called Tour of Heroes and everything has been going smoothly up until this point. At the link above, I've encountered a problem. The code on the left is what the tutorial recommends, but fo ...

Using JavaScript functions within PHP is not supported

Currently, I am utilizing Laravel for my backend operations. Within my setup, there exists a JavaScript function called StartJob() that facilitates Google crawling. In the scenario where I input a keyword, which is then cross-referenced with the database, ...

The response from a Fetch API POST request comes back as a blank text

When I use fetch() to send a post request, the response is coming back empty. Here is my code: JS: async getTotalCompletionTimes() { var res = await fetch("repository/maps.php?method=getcompletiontimes&map="+this.getName(), {method: 'POST&ap ...

Parse the JSON data into an object as well as its nested child object for retrieval

Still getting the hang of JSON and encountering a problem that's not immediately clear to me. The API I'm interacting with returns a standard response object, with the result of the command or request embedded within a data object in the JSON st ...

Resizing a group of 2D SVG shapes in three.js

I'm currently working on creating a map of 2D SVG tiles using three.js. I've utilized SVGLoader() as shown below: loader = new SVGLoader(); loader.load( // resource URL filePath, // called when the resource is loaded ...

Issue with blur event functionality on custom multi-select Vue component not functioning as expected

The blur event seems to be malfunctioning. It works perfectly when I click anywhere within the component, except for when I click on the input field. If I click inside the input field and then outside the component, the blur event fails to trigger, preve ...

Null values from sliders causing issues in dynamic shiny application upon initialization and throughout updates

Working on a complex web application with nested navigation and tabs using R's Shiny package. In some cases, accessing slider values from input$ returns NULL unexpectedly, leading to errors in dependent outputs. To resolve this issue, users can trigg ...

Effect of Active or Focus on the HTML <ul> element

Check out this example of a UL tag: <ul style="list-style-type:none; padding:5px ; border:solid 1px #666666;"> <li>I am waiting </li> <li>I am waiting </li> <li>I am waiting </li> <li>I am wa ...

Remove all Visual Composer Shortcodes while preserving the content

I'm in the process of transferring 200 posts from a previous WordPress website, which contain numerous visual composer shortcodes within the content. Is there a method to remove all the shortcodes and retain the content? ...

The issue with collapsible elements not functioning properly in an Angular application involving CSS and JS

My implementation of collapsible in a plain HTML page looks like this: <!DOCTYPE html> <html> <head> <title></title> <style> button.accordion { background-color: #777; color: white; cursor: pointer; p ...

Indeed, yet another problem with clearInterval

I could use some assistance as I am currently stuck trying to figure out why the stopTimer() function is not working correctly. Any guidance or suggestions would be highly appreciated. Thank you! http://jsfiddle.net/4Efbd/1/ var counter; function endTim ...

In Firefox, the parent div's width is greater than the combined width of its children

In Firefox, I am encountering a peculiar problem. The issue arises when I have a div with a height defined in a fixed px value, and an img element nested within it. While this configuration works fine in Chrome, in Firefox, the parent div's width end ...

Ways to access text content in an HtmlTableCellElement

I am currently working on a jQuery tic-tac-toe project and facing an issue with iterating through the board to save the values of each cell in an array. I have tried using .text() and .value(), but both returned undefined index.html: <html> < ...