Monday, May 20, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
73
rated 0 times [  75] [ 2]  / answers: 1 / hits: 23098  / 13 Years ago, tue, january 3, 2012, 12:00:00

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.



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



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'););
}


Please help me


More From » c#

 Answers
24

put the code in any page event. like page_load,init.. or use RegisterClientScriptBlock


[#88266] Sunday, January 1, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kristinsonjab

Total Points: 364
Total Questions: 98
Total Answers: 98

Location: Christmas Island
Member since Mon, Oct 19, 2020
4 Years ago
kristinsonjab questions
Fri, Mar 4, 22, 00:00, 2 Years ago
Fri, Jan 22, 21, 00:00, 3 Years ago
Fri, Aug 14, 20, 00:00, 4 Years ago
;