Archive for Settembre 11th, 2007

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>   

Reading Xml into DataSet

Settembre 11th, 2007

Description: Reads Xml into DataSet from a given file

Link: http://www.codekeep.net/snippets/eb4cc0ca-2a7f-4060-9103-16d70e6fbf23.aspx

DataSet dsFleets = new DataSet("Fleets");
dsFleets.ReadXml(new System.IO.StreamReader("./Fleets.xml", Encoding.ASCII));