Hi All,

I am new to .Net. I am converting a source which is in .net 1.1 to .net3.5.

In 1.1 those people had used scritps for calendar popup.

Let me show the sample code first

In JSCalendar.aspx

----------------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JSCalendar.aspx.cs" Inherits="JSCalendar" %>

<!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">

<LINK href="cal/popcalendar.css" type="text/css" rel="stylesheet">

<title>Test Calender</title>

<script language="javascript" src="cal/popcalendar.js"></script>

<script language="javascript">

function test()

{

alert('Here');

var strValue = document.getElementById('txt_Date').value;

alert(strValue);

if (strValue != '')

{

var strarr = strValue.split("/");

strValue = strarr[1] + '/' + strarr[0] + '/' + strarr[2];

var d = new Date(strValue);

var d1= d.getDate();

d1 = d1 + 3;

d.setDate(d1);

var Month = d.getMonth();

Month = Month + 1;

strMonth = Month + "";

if(strMonth.length == 1)

Month = '0' + Month;

var strDay = d.getDate() + "";

if(strDay.length == 1)

strDay = '0' + strDay;

document.getElementById('txt_Date1').value = strDay + '/' + Month + '/' + d.getFullYear();

}

}

</script>

</head>

<body>

<form id="form1" method="post" runat="server">

<div>

<TABLE id="tbl_control" cellSpacing="0" cellPadding="0" border="0">

<TR>

<TD align="right"><asp:label id="lbl_Date" Font-Bold="true" runat="server">Date :</asp:label></TD>

<TD align="center" style="width: 107px"><asp:textbox id="txt_Date" runat="server" Columns="6" Width="99px" OnTextChanged="txt_Date_TextChanged"></asp:textbox></TD>

<TD><asp:image id="imgCalendar" runat="server" ImageUrl="cal/calendar.gif"></asp:image></TD>

</TR>

<tr>

<td></td><td style="width: 107px"></td>

</tr>

<TR>

<TD align="right"><asp:label id="lbl_Date1" Font-Bold="true" runat="server">Date 1 :</asp:label></TD>

<TD align="center" style="width: 107px"><asp:textbox id="txt_Date1" runat="server" Columns="6" Width="99px" OnTextChanged="txt_Date1_TextChanged"></asp:textbox></TD>

</TR>

</TABLE>

</div>

<br />

</form>

</body>

</html>

In JSCalendar.aspx.cs

---------------------------------------

using System;

using System.Data;

using System.Configuration;

using System.Collections;

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 JSCalendar : System.Web.UI.Page

{

string scriptStr = null;

protected void Page_Load(object sender, EventArgs e)

{

string scriptStr = "javascript:return popUpCalendar(this," + getClientID() + @", 'dd/mm/yyyy', '__doPostBack(\'" + getClientID() + @"\')')";

imgCalendar.Attributes.Add("onclick", scriptStr);

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}


/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

// Get the id of the control rendered on client side

// Very essential for Javascript Calendar scripts to locate the textbox

public string getClientID()

{

return txt_Date.ClientID;

}

// This propery sets/gets the calendar date

public string CalendarDate

{

get

{

return txt_Date.Text;

}

set

{

txt_Date.Text = value;

}

}

// This Property sets or gets the the label for

// Dateselector user control

public string Text

{

get

{

return lbl_Date.Text;

}

set

{

lbl_Date.Text = value;

}

}

protected void txt_Date_TextChanged(object sender, EventArgs e)

{

//Iam tring to print the value

Response.Write(txt_Date.Text);

}

}

What I am going to do is:

1. calling js for calendar popup and selecting the date.

2. With the date selected I am printing it in the testbox.

3. After getting the date I am calling a function test() in js which will execute in aspx file and will take the value of selected date and will add 3 days more to it and it will print it in another textbox (txt_Date1).

upto now it is ok... I am getting what I am expected.

Now, the problem started for me... when a value or some data is changed in txt_Date... I am calling a method in aspx.cs file called txt_Date1_TextChanged. Here I want to access the values of txt_Date and txt_date1 and also I want to print the values of txt_Date and txt_date1.

Please help me...

Thanks in advance.......

Anil.

Web development forum help better, move your thread there :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.