title: button1.Attributes.Add("onclick", "javascript:window.open('page1.aspx?CheckedItem=" + checkedItem.ToString() + "'');"); is not working properly
body: <p>my client side code button1.Attributes.Add("onclick", "javascript:window.open('page1.aspx?CheckedItem=" + checkedItem.ToString() + "','mywindow',');"); is not executing on the first click.But it is working fine from second click onwards.I wrote this code inside the button click event.</p>
  
  <p>I had tried to put this inside the page_load ,but the problem is i need to return a value from this page.
  here is the code</p>
  
  <pre><code>protected void btnPreview_Click(object sender, EventArgs e)
  {
  
      //StringBuilder checkedItem = new StringBuilder();
      checkedItem.Length = 0;
      foreach (ListItem i in chkValidation.Items)
      {
          if (i.Selected)
          {
              if (string.IsNullOrEmpty(Convert.ToString(checkedItem)))
              {
                  checkedItem.AppendFormat(i.Text);
  
              }
              else
              {
                  checkedItem.AppendFormat(",");
                  checkedItem.AppendFormat(i.Text);
              }
          }
          btn_Preview.Attributes.Add("onclick",
                                     "javascript:window.open('TimePhaseAttributePreview.aspx?CheckedItem=" + 
                                     checkedItem.ToString() + "','mywindow','menubar=0,resizable=0,width=350,height=250');");
      }
  </code></pre>
  
  <p>Please help me</p>