Sir,
I am new in asp.net,
My question was.
If i have two buttons event handlers how to determined in a calendar selectionchange event handler that which button press first than other.i.e "I want to select date from one calendar with two buttons for two textboxes i.e startdate & enddate"
Here i have used Code Please Correct it.
Please correct this code to work I shall be vary thankfull to you.
"''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ublic
partial class Default6 : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
}
protected void Cal1_SelectionChanged(object sender, EventArgs e){
if (btnstart.Enabled.Equals(true)){
txtstart.Text = Cal1.SelectedDate.ToShortDateString();
Cal1.Visible =
false;btnstart.Enabled =
false;btnend.Enabled =
true;}
else{
if (btnend.Enabled.Equals(true))txtend.Text = Cal1.SelectedDate.ToShortDateString();
Cal1.Visible =
false;btnend.Enabled =
false;btnstart.Enabled =
true;}
}
protected void txtstart_TextChanged(object sender, EventArgs e){
}
protected void btnstart_Click(object sender, EventArgs e){
Cal1.Visible =
true; // txtstart.Text = Cal1.SelectedDate.ToShortDateString(); // Cal1.Visible = false;}
protected void txtend_TextChanged(object sender, EventArgs e){
}
protected void btnend_Click(object sender, EventArgs e){
Cal1.Visible =
true; // txtend.Text = Cal1.SelectedDate.ToShortDateString(); // Cal1.Visible = false;}
paiha paigaPosted Oct 30, 2008, 4:49 AM
Use this code in inline
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml" ><
head runat="server"> <title>Untitled Pagetitle> head><
body> <form id="form1" runat="server"> <div> <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged"> asp:Calendar> <asp:Button ID="Button1" runat="server" Text="Start Date" OnClick="Button1_Click" /> <asp:TextBox ID="TextBox1" runat="server">asp:TextBox> <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="End Date" /> <asp:TextBox ID="TextBox2" runat="server">asp:TextBox>div> form> body> html>and use this below code in code behind of the ASPX page and see the result, it will fulfill your requirement.
using
System;using
System.Data;using
System.Configuration;using
System.Web;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls;public
partial class _Default : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
Calendar1.Visible =
false; if (!IsPostBack){
Button2.Enabled =
false;}
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e){
if (TextBox2.Text == "" && TextBox1.Text == ""){
TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
Button1.Enabled =
false;}
else{
TextBox2.Text = Calendar1.SelectedDate.ToShortDateString();
}
Calendar1.Visible =
false;}
protected void Button1_Click(object sender, EventArgs e){
Calendar1.Visible =
true;Button2.Enabled =
true;}
protected void Button2_Click(object sender, EventArgs e){
Calendar1.Visible =
true;TextBox2.Text =
"";}
}
Thanks and enjoy with this and try it in order to see the result.