how to increment and decrement date in asp.net -


how increment , decrement date in asp.net..

i have tried following code..

or there alternative javascript..?

    {       string dt;     protected void page_load(object sender, eventargs e)     {         dt = datetime.now.toshortdatestring().tostring();         date.text = dt;     }      protected void decr_click(object sender, eventargs e)     {         date.text = convert.todatetime(date.text).adddays(-1).toshortdatestring().tostring();              }      protected void incr_click(object sender, eventargs e)     {         date.text =convert.todatetime(date.text).adddays(1).toshortdatestring().tostring();               } 

wrap code of page_load event in if (!page.ispostback)

 protected void page_load(object sender, eventargs e)         {             if (!page.ispostback)             {                 dt = datetime.now.toshortdatestring().tostring();                 date.text = dt;             }         } 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -