用于后台输出Javascript执行段

打开一个新窗口:

Page.RegisterStartupScript("starup", "<script language = 'javascript'>window.open('" + url + "','','toolbar=no,resizable=yes,scrollbars=yes')</script>")

警告窗口
/// <summary>
///
服务器端弹出alert对话框
/// </summary>
/// <param name="str_Message">
提示信息,例子:"不能为空!"</param>
/// <param name="page">Page
</param>
public void Alert(string str_Message,Page page)
{
page.RegisterStartupScript("","<script>alert('"+str_Message+"');</script>");
}

重载此警告窗口,使某控件获得焦点

/// <summary>
///
服务器端弹出alert对话框,并使控件获得焦点
/// </summary>
/// <param name="str_Ctl_Name">
获得焦点控件Id,比如:txt_Name</param>
/// <param name="str_Message">
提示信息,例子:"请输入您姓名!"</param>
/// <param name="page">Page
</param>
public void Alert(string str_Ctl_Name,string str_Message,Page page)
{
page.RegisterStartupScript("","<script>alert('"+str_Message+"');document.forms(0)."+str_Ctl_Name+".focus(); document.forms(0)."+str_Ctl_Name+".select();</script>");
}

确认对话框

/// <summary>
///
服务器端弹出confirm对话框
/// </summary>
/// <param name="str_Message">
提示信息,例子:"您是否确认删除!"</param>
/// <param name="btn">
隐藏Botton按钮Id,比如:btn_Flow</param>
/// <param name="page">Page
</param>
public void Confirm(string str_Message,string btn,Page page)
{
page.RegisterStartupScript("","<script> if (confirm('"+str_Message+"')==true){document.forms(0)."+btn+".click();}</script>");
}

重载确认对话框,点击确定触发一个隐藏按钮事件,点击取消触发一个隐藏按钮事件

/// <summary>
///
服务器端弹出confirm对话框,询问用户准备转向那些操作,包括确定取消时的操作
/// </summary>
/// <param name="str_Message">
提示信息,比如:"成功增加数据,单击""确定""按钮填写流程,单击""取消""修改数据"</param>
/// <param name="btn_Redirect_Flow">"
确定"按钮id</param>
/// <param name="btn_Redirect_Self">"
取消"按钮id</param>
/// <param name="page">Page
</param>
public void Confirm(string str_Message,string btn_Redirect_Flow,string btn_Redirect_Self,Page page)
{
page.RegisterStartupScript("","<script> if (confirm('"+str_Message+"')==true){document.forms(0)."+btn_Redirect_Flow+".click();}else{document.forms(0)."+btn_Redirect_Self+".click();}</script>");
}


获得焦点

/// <summary>
///
使控件获得焦点
/// </summary>
/// <param name="str_Ctl_Name">
获得焦点控件Id,比如:txt_Name</param>
/// <param name="page">Page
</param>
public void GetFocus(string str_Ctl_Name,Page page)
{
page.RegisterStartupScript("","<script>document.forms(0)."+str_Ctl_Name+".focus(); document.forms(0)."+str_Ctl_Name+".select();</script>");
}

子窗体返回主窗体

///<summary>
///
名称:redirect
///
功能:子窗体返回主窗体
///
参数:url
///
返回值:空
///</summary>
public void redirect(string url,Page page)
{
if ( Session["IfDefault"]!=(object)"Default")
{
page.RegisterStartupScript("","<script>window.top.document.location.href='"+url+"';</script>");
}
}

posted on 2009-09-05 16:24  opper  阅读(1026)  评论(0编辑  收藏  举报

青丝网

脱发治疗

www.faako.com