0

Hello,

I am opening a calendar popup when user clicks on a button but here I have to click twice to get this calendar. On the 1st click it doe not do anything but on 2nd click it shows up the calendar.
here is my code-

<script type="text/javascript" >
    function openCalender_range_start_date() {
        window.open('popupcalendar.aspx?textbox=TextBox2', 'cal', 'width=220,height=200,left=270,top=180')
}

and on popupcalendar.aspx-

protected void Change_Date(System.Object sender, System.EventArgs e)
{
    if (Request.QueryString["TextBox2"] != "")
  {
    string strScript = 
        "<script>window.opener.document.forms(0)." + 
        Request.QueryString["textbox"].ToString() + ".value = '" +
        Calendar1.SelectedDate.ToString("MM/dd/yyyy") +
        "';self.close()" +
        "</" + "script>"; 
    RegisterClientScriptBlock("Calendar_ChangeDate", strScript);

}
}

and on the button- Button2.Attributes.Add("onclick", "openCalender_range_start_date();"); Can somebody tell me what I am doing wrong?

2
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by LizR
0

When you say

Hello,
and on the button- Button2.Attributes.Add("onclick", "openCalender_range_start_date();");

Can you show the whole line? it could be how you've placed this code.

0

that's what i have as my complete line of code.

0

Ok but where is that line of code? if its in the "onclick" that would explain it

0

My code is-

protected void Button2_Click1(object sender, EventArgs e)
{


Button2.Attributes.Add("onclick", "openCalender_range_start_date();");
}

What is that I am doing wrong?

Edited by happygeek: fixed formatting

0

exactly what I suggested you'd done

the first time you click it, you then tell it on clicking it to do something else, so its not there the first time... but is the second..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.