首页 > 应用开发 > IT综合 > Asp.net 2.0中常用方法整理

/**////
/// 一些常用的Js调用
///
public class Jscript
{
/**////
/// 弹出JavaScript小窗口
///
/// 窗口信息
public static void Alert(string message)
{
#region
string js = @"";
HttpContext.Current.Response.Write(js);
#endregion
}

/**////
/// 弹出消息框并且转向到新的URL
///
/// 消息内容
/// 连接地址
public static void AlertAndRedirect(string message, string toURL)
{
#region
string js = "";
HttpContext.Current.Response.Write(string.Format(js, message, toURL));
#endregion
}

/**////
/// 回到历史页面
///
/// -1/1
public static void GoHistory(int value)
{
#region
string js = @"";
HttpContext.Current.Response.Write(string.Format(js, value));
#endregion
}

/**////
/// 关闭当前窗口
///
public static void CloseWindow()
{
#region
string js = @"";
HttpContext.Current.Response.Write(js);
HttpContext.Current.Response.End();
#endregion
}

/**////
/// 刷新父窗口
///
public static void RefreshParent(string url)
{
#region
string js = @"";
HttpContext.Current.Response.Write(js);
#endregion
}

/**////
/// 刷新打开窗口
///
public static void RefreshOpener()
{
#region
string js = @"";
HttpContext.Current.Response.Write(js);
#endregion
}


/**////
/// 打开指定大小的新窗体
///
/// 地址
/// 宽
/// 高
/// 头位置
/// 左位置
public static void OpenWebFormSize(string url, int width,int heigth,int top,int left)
{
#region
string js = @"";
HttpContext.Current.Response.Write(js);
#endregion
}

/**////
/// 转向Url制定的页面
///
/// 连接地址
public static void JavaScriptLocationHref(string url)
{
#region
string js = @"";
js = string.Format(js, url);
HttpContext.Current.Response.Write(js);
#endregion
}

/**////
/// 打开指定大小位置的模式对话框
///
/// 连接地址
/// 宽
/// 高
/// 距离上位置
/// 距离左位置
public static void ShowModalDialogWindow(string webFormUrl, int width, int height, int top, int left)
{
#region
string features = "dialogWidth:" + width.ToString() + "px"
+ ";dialogHeight:" + height.ToString() + "px"
+ ";dialogLeft:" + left.ToString() + "px"
+ ";dialogTop:" + top.ToString() + "px"
+ ";center:yes;help=no;resizable:no;status:no;scroll=yes";
ShowModalDialogWindow(webFormUrl, features);
#endregion
}
public static void ShowModalDialogWindow(string webFormUrl, string features)
{
string js = ShowModalDialogJavascript(webFormUrl, features);
HttpContext.Current.Response.Write(js);
}
public static string ShowModalDialogJavascript(string webFormUrl, string features)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/390618/viewspace-986969/ ,如需转载,请注明出处,否则将追究法律责任。