Click here to Skip to main content
15,887,454 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi,

I m developing web application in asp.net with c# in which i m having

2 web form.

First web page is connected with masterpage.
Second is not connected with master page

in both webpage i m taking textbox for date
i m using aspx calendar control for taking date it.

Second webpage is running fine, which is not connected with masterpage.

But in first i m getting problem ,for taking date from aspx calender control.
in this case calender is shown in image, click but when i select date from calender, i m not getting date in textbox

My aspx code is show below:

XML
<script language="javascript">
      function PopupPicker(ctl) {
          var PopupWindow = null;
          PopupWindow = window.open('DatePicker.aspx?ctl=' + ctl, 'zx', 'width=250,height=250');
          PopupWindow.focus();
      }
  </script>



<asp:TextBox ID="txtDate" runat="server"><img src="images/btnimg.jpg"
style="margin-top:3px;width:30px;height:13px; cursor:hand;" alt=""
önclick="PopupPicker('txtDate')" />

and datepicker.aspx code is shown below

XML
<script language="javascript">
        function SetDate(dateValue, ctl) {
            thisForm = window.opener.document.forms[0].elements[ctl].value = dateValue;
            self.close();
        }
    </script>



C#
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        string ctrl = Request.QueryString["ctl"];
        HyperLink hpl = new HyperLink();
        hpl.Text = ((LiteralControl)e.Cell.Controls[0]).Text;
        hpl.NavigateUrl = "javascript:SetDate('" + e.Day.Date.ToShortDateString() + "','" + ctrl + "');";
        e.Cell.Controls.Clear();
        e.Cell.Controls.Add(hpl);
    }


can anyone help me pls
Posted

1 solution

Hi jeet !

From what I understood . You have a Calendar control in your webpage and you want to make sure that whenever a date is picked in the calendar control it is reflected in the textbox in the same page,

If this is what you meant. ?

Drag a textbox, button(to show the calendar on click) and calendar control.

On the selectionchanged event of the calendar

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
string test = Calendar1.SelectedDate.ToShortDateString();

TextBox1.Text = test;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900