关于脚本注册的问题还没有解决,继续散分……
极客行天下 2006-09-29 02:40:42 http://community.csdn.net/Expert/topic/5054/5054943.xml?temp=.510647
拼字串的问题已经解决。
现在我的问题是(vs2005下实现的):
string str = "<script language=javascript>function openWin(){";
str += "window.open('hello.html','name','height=510,width=600,resizable=no,left=' + (screen.availWidth-600)/2 + ',top=' + (screen.availHeight-510)/2);}<";
str += "/";
str += "script>";
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsClientScriptBlockRegistered("clientScript"))
{
cs.RegisterClientScriptBlock(this.GetType(), "clientScript", str);
}
Response.Write("<script>openWin</script>");
会有脚本错误:未找到openWin
这些代码是放在page_load事件下的,如果去掉Response.Write("<script>openWin</script>");在页面加载后执行脚本函数openWin是没有问题的,这说明脚本是成功注册了的。关键是Response.Wrtie这里的问题。
请帮忙看看有什么好的解决方案,谢谢!