954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Have to click twice on calendar pop up

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?

absu
Newbie Poster
6 posts since Oct 2008
Reputation Points: 10
Solved Threads: 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.

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

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

absu
Newbie Poster
6 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

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

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

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?

absu
Newbie Poster
6 posts since Oct 2008
Reputation Points: 10
Solved Threads: 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..

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You