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
Post a Comment