Click to See Complete Forum and Search --> : codes for blocking dates on hotel reservation projects
cakamaya
04-25-2009, 12:06 AM
hii everyone..
please help me in my small projects about reservation dates in hotels..
or give me some lead on how to write the codes, i've just starting to learn asp.net....
i'm using visual studio 2005 and microsoft sql server 2005
thanks all
mrinmoy
04-29-2009, 07:05 AM
are you looking something like booking hotels online?
cakamaya
04-29-2009, 06:56 PM
yes....... i'm still confuse about how to block dates. my friend told me to use DateTimePicker on visual studio, but i cant find DateTimePicker on my visual studio 2005
could you give some examples please....
now i just using two input date format
one for date_in and one for date_out.......how should i make blocking for dates between the two dates....?
mrinmoy
04-29-2009, 11:10 PM
ASPX Code......
<script type="text/javascript" src="calendar/calendar.js"/>
<script type="text/javascript" src="calendar/calendar-en.js"/>
<script type="text/javascript" src="calendar/calendar-setup.js"/>
<script type="text/javascript" language="javascript">
function InitCalendars()
{
Calendar.setup
(
{
inputField : "txtFromDate", // id of the input field
//ifFormat : "%d-%mm-%Y", // format of the input field
ifFormat : "%m/%d/%Y",
button : "btnFromDate", // trigger for the calendar (button ID)
align : "Tl", // alignment (defaults to "Bl")
singleClick : true
}
);
Calendar.setup
(
{
inputField : "txtToDate", // id of the input field
//ifFormat : "%d-%mm-%Y", // format of the input field
ifFormat : "%m/%d/%Y",
button : "btnToDate", // trigger for the calendar (button ID)
align : "Tl", // alignment (defaults to "Bl")
singleClick : true
}
);
return false;
}
</script>
<body onload="InitCalendars();">
<asp:Label ID="lblFromDate" runat="server" Text="From:" Font-Bold="False" Font-Size="Small"></asp:Label>
<asp:TextBox ID="txtFromDate" runat="server" AutoPostBack="True" Font-Names="Arial" Font-Size="10pt" OnTextChanged="txtFromDate_TextChanged" Width="115px"></asp:TextBox>
<img id="btnFromDate" runat="server" alt="Pick Date" height="16" onmouseover="this.style.cursor='hand'" src="Images/datePick.gif" width="16" />
<asp:Label ID="lblTo" runat="server" Font-Bold="False" Font-Size="Small" Text="To:"></asp:Label>
<asp:TextBox ID="txtToDate" runat="server" AutoPostBack="True" Font-Names="Arial" Font-Size="10pt" OnTextChanged="txtToDate_TextChanged" Width="115px"></asp:TextBox>
<img id="btnToDate" runat="server" alt="Pick Date" height="16" onmouseover="this.style.cursor='hand'" src="Images/datePick.gif" width="16" />
</body>
ASPX.CS code....
protected void txtFromDate_TextChanged(object sender, EventArgs e)
{
string fromDateString = txtFromDate.Text;
DateTime startDate = Convert.ToDateTime(fromDateString);
string toDateString = txtToDate.Text;
DateTime endDate = Convert.ToDateTime(toDateString);
if (DateTime.Compare(startDate, endDate) > 0)// May be your another condition
{
Page.RegisterStartupScript("javascript", "<script>alert('\"From date\" must be less than \"To date\"')</script>");
txtToDate.Text = fromDateString;
}
else
{
// Your further code
}
}
I have attached "Try this.zip" for your reference.
cakamaya
04-30-2009, 08:23 AM
thank you so much mrinmoy............:D:D:D:D:D
>>>>>> testing the codes right away.........:):):)
n thans to for the references ^^v