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?

When you say

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.

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

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

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 3 Years Ago by happygeek: fixed formatting

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 article has been dead for over six months. Start a new discussion instead.