Ajax Calendar

Settembre 11th, 2007

Description: Ajax Calendar and TextBox Date input

Link: http://www.codekeep.net/snippets/7c384cdc-7ab2-4849-a848-c0f67de49dd2.aspx

//C# Code
   protected void clrExpDate_SelectionChanged(object sender, EventArgs e)
        {
            Calendar clr = sender as Calendar;
            this.tbExpDate.Text = clr.SelectedDate.ToShortDateString();
            clr.TodaysDate = clr.SelectedDate;
        }

 protected void tbDate_TextChanged(object sender, EventArgs e)
    {
        string s = this.tbDate.Text;
        try
        {
            this.clrDate.TodaysDate = Convert.ToDateTime(((TextBox)sender).Text);
            this.clrDate.SelectedDate = this.clrDate.TodaysDate;
            _updateMeals();
        }
        catch
        {
            this.lblDataErrMsg.Text = "Date format not valid!";
        }
    } 

 protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        this.imgDate.Attributes.Add("onclick", "var pnl = document.getElementById('" + this.divCalendar.ClientID + "'); if(pnl){if(pnl.style.display == 'none'){pnl.style.display = 'inline';} else{pnl.style.display = 'none';}} return false;");
        this.lnkCalendarClose.Attributes.Add("onclick", "var pnl = document.getElementById('" + this.divCalendar.ClientID + "'); pnl.style.display = 'none'; return false;");
}

//Html Code

<table>
                                        <tr>
                                            <td>
                                                <anthem:TextBox/>
                                                </td>
                                            </tr>
                                        </table>

                                    </div>   

  • .NET
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.