ScriptManager.RegisterStartupScript()问题

liss_2009 2010-03-17 05:19:47
ScriptManager.RegisterStartupScript("Zhaobiao.aspx", this.GetType(), "waring", "window.open('Product.aspx?productid=" + productid + "&userid=" + users.User_id + "','_blank','width=550,height=400,status=no,resizable=no,location=center,Toolbar=no,menubar=no,directories=no,scrollbars=no');", true);
ScriptManager.RegisterStartupScript()中的第一个参数应该是什么?
我知道的ScriptManager.RegisterStartupScript()的第一个参数可以是控件,也可以是page,我现在想如果是传page的话,应该是当前web窗体的名字吗?我传了一个,但报错了,报的错是没有匹配的参数!


请各位高手帮帮忙!先谢了!
...全文
401 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
liss_2009 2010-03-18
  • 打赏
  • 举报
回复
哈哈,已解决,谢谢!
wiki14 2010-03-17
  • 打赏
  • 举报
回复
如:


ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "heightR", "<script src=\"js/heightMax.js\" type=\"text/javascript\"></script>", false);

阿非 2010-03-17
  • 打赏
  • 举报
回复
ScriptManager.RegisterStartupScript(this, this.GetType(), "waring", "window.open('Product.aspx?productid=" + productid + "&userid=" + users.User_id + "','_blank','width=550,height=400,status=no,resizable=no,location=center,Toolbar=no,menubar=no,directories=no,scrollbars=no');", true);
wiki14 2010-03-17
  • 打赏
  • 举报
回复
page
类型:System.Web.UI..::.Page
第一个参数为正在注册该客户端脚本块的页对象。
<script type="text/C#" runat="server"> BinaryReader ms; UploadInfo uploadInfo = null; protected void Page_Load(object sender, EventArgs args) { if (this.IsPostBack) { uploadInfo = this.Session["UploadInfo"] as UploadInfo; if (uploadInfo == null) { // 让父页面知道无法处理上传 const string js = "window.parent.onComplete('error', '无法上传文件。请刷新页面,然后再试一次);"; ScriptManager.RegisterStartupScript(this, typeof(upload_aspx), "progress", js, true); } else { // 让服务端知道我们还没有准备好.. uploadInfo.IsReady = false; try { // 读取要上传的文件 FileStream fs = new FileStream(this.fileUpload.PostedFile.FileName, FileMode.Open, FileAccess.Read); ms = new BinaryReader(fs); string newFile = DateTime.Now.Ticks.ToString(); string exit = this.fileUpload.FileName.Substring(this.fileUpload.FileName.IndexOf('.')); newFile = newFile + exit; UriBuilder url = new UriBuilder("http://192.168.25.27:8056/UploadFileHander.ashx");//上传路径 url.Query = string.Format("filename={0}", newFile);//上传url参数 uploadInfo.ContentLength = this.fileUpload.PostedFile.ContentLength; uploadInfo.FileName = newFile; uploadInfo.UploadedLength = 0; //文件存在 初始化... uploadInfo.IsReady = true; WebClient wc = new WebClient(); wc.Credentials = CredentialCache.DefaultCredentials; wc.OpenWriteCompleted += new OpenWriteCompletedEventHandler(wc_OpenWriteCompleted);//委托异步上传事件 wc.OpenWriteAsync(url.Uri);//开始异步上传 const string js = "window.parent.onComplete('success', '{0} 已成功上传,重命名为:{1}:文件大小:{2}');"; ScriptManager.RegisterStartupScript(this, typeof(upload_aspx), "progress", string.Format(js, Path.GetFileName(this.fileUpload.FileName), DateTime.Now.ToString("yyyy-MM") + "/" + DateTime.Now.Day + "/" + newFile, uploadInfo.ContentLength), true); } catch (Exception ex) { Response.Write(ex.Message); } } } } protected void wc_OpenWriteCompleted(object sender, OpenWriteCompletedEventArgs e) { int bufSize = 10; int byteGet = 0; byte[] buf = new byte[bufSize]; while ((byteGet = ms.Read(buf, 0, bufSize)) > 0)//循环读取,上传 { e.Result.Write(buf, 0, byteGet);//注意这里 uploadInfo.UploadedLength += byteGet; } // 让父页面知道已经处理上传完毕 e.Result.Close();//关闭 ms.Close(); } script>

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧