基本信息
源码名称:asp.net 服务器端对话框实现
源码大小:1.11KB
文件格式:.rar
开发语言:C#
更新时间:2013-10-28
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System; using System.Text; using System.Web.UI; using System.ComponentModel; using System.Collections.Specialized; using System.Web.UI.Design; using System.Resources; using jjstar.AspNetWebControl.Design; namespace jjstar.AspNetWebControl { [Designer(typeof(WebControlDesigner))] public class WebConfirm : System.Web.UI.WebControls.TextBox // System.Web.UI.Control, System.Web.UI.IPostBackEventHandler { private bool blDoConfirm; public event EventHandler ConfirmOK; public event EventHandler ConfirmCancel; private bool DoConfirm { get{return blDoConfirm;} set{blDoConfirm = value;} } [Category("行为"),Description("对话框上的确认提示信息。")] public string ConfirmMessage { get { object obj=ViewState["Msg"]; return ((null ==obj ) ? null : (string)obj); } set{ViewState["Msg"] = value;} } [Browsable(false)] public override bool Visible { get{return false;} } protected override void Render(HtmlTextWriter output) { base.Render(output); output.Write("<br>"); } protected override void OnPreRender(EventArgs e) { if (true==blDoConfirm) { if((null==ConfirmOK)&&(null==ConfirmCancel)){} else { Page.GetPostBackEventReference(this); StringBuilder sbScript=new StringBuilder(); sbScript.Append("<script language='javascript'>") .Append("var " this.ID "flag=confirm('" ConfirmMessage "');"); if(null!=ConfirmOK) { sbScript.Append("if(true==" this.ID "flag)") .Append(Page.GetPostBackEventReference(this,"ok") ";"); } if(null!=ConfirmCancel) { sbScript.Append("if(false==" this.ID "flag)") .Append(Page.GetPostBackEventReference(this,"cancel") ";"); } sbScript.Append("</script>"); Page.RegisterStartupScript(this.UniqueID "Confirm",sbScript.ToString()); } } base.OnPreRender(e); } public virtual void ShowConfirm() { DoConfirm=true; } public virtual void ShowConfirm(string confirmMessage) { ConfirmMessage=confirmMessage; ShowConfirm(); } private bool LoadPostData(string postDataKey,NameValueCollection postData) { string PostedValue=postData[postDataKey]; string val=ConfirmMessage; if(null==PostedValue||val!=PostedValue) { ConfirmMessage=PostedValue; return true; } return false; } public void RaisePostBackEvent(string eventArgument) { if(eventArgument.ToUpper()=="OK") OnConfirmOK(); if(eventArgument.ToUpper()=="CANCEL") OnConfirmCancel(); } protected void OnConfirmOK() { if(null!=ConfirmOK) ConfirmOK(this,new EventArgs()); } protected void OnConfirmCancel() { if(null!=ConfirmCancel) ConfirmCancel(this,new EventArgs()); } } }