ASP.NET服务器控件PleaseWaitButton
ascript code is kept // in an embedded resource; load the script // and register it with the page. RegisterJavascriptFromResource(); } private void RegisterJavascriptFromResource() { // load the embedded text file "javascript.txt" // and register its contents as client-side script string sScript = GetEmbeddedTextFile("javascript.txt"); this.Page.RegisterClientScriptBlock("PleaseWaitButtonScript", sScript); } private string GetEmbeddedTextFile(string sTextFile) { // generic function for retrieving the contents // of an embedded text file resource as a string // we''ll get the executing assembly, and derive // the namespace using the first type in the assembly Assembly a = Assembly.GetExecutingAssembly(); String sNamespace = a.GetTypes()[0].Namespace; // with the assembly and namespace, we''ll get the // embedded resource as a stream Stream s = a.GetManifestResourceStream( string.Format("{0}.{1}", sNamespace, sTextFile) ); // read the contents of the stream into a string StreamReader sr = new StreamReader(s); String sContents = sr.ReadToEnd(); sr.Close(); s.Close(); return sContents; } javascript.txt嵌入资源包含了按钮在Javascript的onclick句柄中执行的客户端方法PleaseWait()。这段代码也调用了一个客户端方法HideDiv()以隐藏按钮的容器<div>,然后通过设置innerHTML属性把信息或图像组装进之前空的<div>标记中。辅助函数GetDiv()则是通过检查document.getElementById, document.all, 和 document.layers用id返回一个<div>对象,保证了不同浏览器的兼容性。下面是javascript.txt的全部代码:
|
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |