user190618
user190618

Reputation:

date increase in asp.net

i want to increase & decrease date on button click like this < 11\11\09 > . '<' for decrease and '>' for increment. kindly help me to do so.

Upvotes: 0

Views: 565

Answers (2)

TheVillageIdiot
TheVillageIdiot

Reputation: 40497

Please use jQuery. Get datejs then its all breeze!

<span class="spBtn" increment="-1">&lt;</span>
<span id="spDate">11\11\2009</span>
<span class="spBtn" increment="1">&gt;</span>

$(document).ready(function(){
    $("span.spBtn").click(function(){
        var dstr=$("span#spDate").text();
        dstr=dstr.replace(/\\/g,'.');
        var d=Date.parseExact(dstr,"d.M.yyyy");
        var i=$(this).attr("increment");
        d=d.addDays(i);
        $("span#spDate").text(d.toString("d\\M\\yyyy"));
    });
});

Upvotes: 1

Ivo
Ivo

Reputation: 3436

You can bind the click events of the >(make it a button or image) and then in the codebehind you can do something with date.add. http://authors.aspalliance.com/aspxtreme/sys/DateTimeClassAdd.aspx

But I advice you not to do it in ASP.NET, but use jquery for this. So you can do this without a roundtrip

Upvotes: 2

Related Questions