Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
I have an asp button. When i click this button it will be disabled. I want it to enable on a particular date of every month. How will i do? Please help. Thanks in advance. 


What I have tried:

I have searched google. but i did not find it.
Posted
Updated 14-Nov-16 23:30pm

C#
DateTime dt = DateTime.Now;

// Change "5" to the day you are interested in
if (dt.Day == 5)
{
    // enable button
}
else
{
    // disable button
}
 
Share this answer
 
Write in the page load event
C#
protected void Page_Load(object sender, EventArgs e)
        {
            int dayToEnable = 10; // 10th of every month
            btnID.Enabled = false;
            if (DateTime.Today.Day == dayToEnable)
                btnID.Enabled = true;
        }
 
Share this answer
 
Comments
Mohammed Jaleel 19-Feb-21 13:21pm    
sir how to get 10th of every year
Karthik_Mahalingam 30-Dec-22 1:22am    
question is incomplete

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900