Response.Write("<script>window.opener.document.getElementById('Tabs_Panel1_TextBoxCategoryID').value='" + CategoryID.ToString() + "';window.opener.document.getElementById('Tabs_Panel1_TextBoxSelectCategoryName').value='" + CategoryName + "';window.opener.document.getElementById('Tabs_Panel1_TextBoxCategoryName').value='" + CategoryName + "';window.close();</script>");
如果CategoryName有单引号,就会出错,如何解决这个问题?
------解决方案--------------------------------------------------------
Response.Write(" <script>window.opener.document.getElementById('Tabs_Panel1_TextBoxCategoryID').value='" + CategoryID.ToString() + "';
var categoryName=\""+CategoryName+"\";
window.opener.document.getElementById('Tabs_Panel1_TextBoxSelectCategoryName').value=categoryName+ "';window.opener.document.getElementById('Tabs_Panel1_TextBoxCategoryName').value=categoryName;window.close(); </script>");
这样定义一个javascript的变量,用双引号分隔,试试