弹出提示框包含增加,修改,删除,成功或者失败操作提示信息方法封装
前台调用方法:
bool result =false;
if (result)
new MessageBox(Page).ShowAndJump("添加成功!", "List.aspx");
else
new MessageBox(this.Page).Show("添加失败!");
弹出提示框包含增加,修改,删除,成功或者失败操作提示信息方法封装:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI;
namespace ToolsCommon
{
public class MessageBox
{
private Control _fromctrl;
private Page _fromPage;
#region 构造页面和用户控件操作
public MessageBox(Page frompage)
{
_fromPage = frompage;
}
public MessageBox(UserControl fromctrl)
{
_fromctrl = fromctrl;
}
#endregion
/// <summary>
/// 弹出提示信息,页面禁止空白显示
/// </summary>
/// <param name="messagetext"></param>
public void Show(string messagetext)
{
string LableId;
LableId = Guid.NewGuid().ToString(N);
Label lable1 = new Label();
lable1.ID = msg + LableId;
lable1.Text = String.Format(script language=javascriptwindow.alert('{0}');script, messagetext);
lable1.Visible = true;
if (_fromctrl == null)
_fromPage.Controls.Add(lable1);
else
_fromctrl.Page.Controls.Add(lable1);
}
/// <summary>
/// 跳转指定页面方法
/// </summary>
/// <param name="newurl">要转向的路径地址</param>
public void Jump(string newurl)
{
string LableId;
LableId = Guid.NewGuid().ToString(N);
Label lable1 = new Label();
lable1.ID = msg + LableId;
lable1.Text = String.Format(script language=javascriptwindow.location.href='{0}';script, newurl);
lable1.Visible = true;
if (_fromctrl == null)
_fromPage.Controls.Add(lable1);
else
_fromctrl.Page.Controls.Add(lable1);
}
/// <summary>
/// 弹出提示信息,页面禁止空白,转向指定页面
/// </summary>
/// <param name="messagetext">弹出提示信息</param>
/// <param name="newrul">转向指定页面路径</param>
public void ShowAndJump(string messagetext, string newrul)
{
Show(messagetext);
Jump(newrul);
}
}
}

浙公网安备 33010602011771号