internal void CheckForUpdate(ref Page page) { Operation operation; if (!TryGetLatestOperation(out operation, ref page)) { if (page.GetType().BaseType != typeof (Error)) { RedirectToErrorPage(ref page); } } else { if (operation == null) { if (page.GetType().BaseType != typeof (Idle)) { RedirectToNoAlarm(ref page); } } else { if (operation.Id.ToString(CultureInfo.InvariantCulture) == HttpContext.Current.Request["id"]) { if (operation.IsAcknowledged) { RedirectToNoAlarm(ref page); } } else { page.Response.Redirect("Default.aspx?id=" + operation.Id); } } } }
/// <summary> /// 回到历史页面 /// </summary> /// <param name="value">-1/1</param> public static void GoHistory(int value, Page page) { string js = @"<script type='text/javascript'> history.go({0}); </script>"; if (page.ClientScript.IsStartupScriptRegistered(page.GetType(), "gohistory")) page.ClientScript.RegisterStartupScript(page.GetType(), "gohistory", js); }
/// <summary> /// 弹出消息框并跳转向到新的URL /// </summary> /// <param name="message">消息内容</param> /// <param name="toURL">跳转页面的地址</param> /// <param name="page">当前页面对象,如this.Page</param> public static void AlertAndRedirect(string message, string toURL, Page page) { string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>"; if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "AlertAndRedirect")) { page.ClientScript.RegisterStartupScript(page.GetType(), "AlertAndRedirect", string.Format(js, message, toURL)); } }
/// <summary> /// 关闭当前窗口 /// </summary> public static void CloseWindow(Page page) { string js = @"<script type='text/javascript'> parent.opener=null;window.close(); </script>"; if (page.ClientScript.IsStartupScriptRegistered(page.GetType(), "close")) page.ClientScript.RegisterStartupScript(page.GetType(), "close", js); }
/// <summary> /// 将传入的Javascript字符串值作为代码执行 /// </summary> /// <param name="jsContent">传入的Javascript字符</param> /// <param name="page">相关的页面</param> public static void ExcuteJavascriptCode(string jsContent,Page page) { string js = "<script language=javascript>" + jsContent + "</script>"; if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "ExcuteJavascriptCode")) { page.ClientScript.RegisterStartupScript(page.GetType(), "ExcuteJavascriptCode",js); } }
/// <summary> /// 转向指定的Url /// </summary> /// <param name="html"></param> public static void LocationNewHref(string url, Page page) { string js = @"<script type='text/javascript'> window.location.replace('{0}'); </script>"; js = string.Format(js, url); if (page.ClientScript.IsStartupScriptRegistered(page.GetType(), "location")) page.ClientScript.RegisterStartupScript(page.GetType(), "location", js); }
public static void AlertSuccess(string message, Page page) { #region string js = @"<Script language='JavaScript'>ymPrompt.setDefaultCfg({title:'Title',okTxt:' OK ',cancelTxt:' Cancel ',closeTxt:'Close',minTxt:'Minimize',maxTxt:'Maximize'});ymPrompt.succeedInfo('" + message + "',null,null,null,null);</Script>"; if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "alert")) { page.ClientScript.RegisterStartupScript(page.GetType(), "alert", js); } #endregion }
/// <summary>弹出JavaScript小窗口</summary> /// <param name="message">提示信息</param> /// <param name="page">Web窗体页</param> public static void AlertJS(string message, Page page) { #region string js = @"<Script language='JavaScript'>alert('" + message + "');</Script>"; if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "alert")) { page.ClientScript.RegisterStartupScript(page.GetType(), "alert", js); } #endregion }
/// 回到历史页面 </summary> /// <param name="value">-1/1</param> /// <param name="page">Web窗体页</param> public static void GoHistory(int value, Page page) { #region string js = @"<Script language='JavaScript'>history.go({0});</Script>"; if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "GoHistory")) { page.ClientScript.RegisterStartupScript(page.GetType(), "GoHistory", string.Format(js, value)); } #endregion }
/// <summary> /// 弹出消息框并且转向到新的URL /// </summary> /// <param name="message">消息内容</param> /// <param name="toURL">连接地址</param> public static void AlertAndRedirect(string message, string toURL, Page page) { #region string js = "<script type='text/javascript'>alert('{0}');window.location.replace('{1}')</script>"; //HttpContext.Current.Response.Write(string.Format(js, message, toURL)); if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "AlertAndRedirect")) { page.ClientScript.RegisterStartupScript(page.GetType(), "AlertAndRedirect", string.Format(js, message, toURL)); } #endregion }
/// <summary>转向Url制定的页面 </summary> /// <param name="url">连接地址</param> /// <param name="page">Web窗体页</param> public static void JavaScriptLocationHref(string url, Page page) { #region string js = @"<Script language='JavaScript'>window.location.replace('{0}');</Script>"; js = string.Format(js, url); if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "JavaScriptLocationHref")) { page.ClientScript.RegisterStartupScript(page.GetType(), "JavaScriptLocationHref", js); } #endregion }
/// <summary> /// 向当前页面动态输出客户端脚本代码 /// </summary> /// <param name="javascript">javascript脚本段</param> /// <param name="page">Page类的实例</param> /// <param name="afterForm">是否紧跟在<form>标记之后输出javascript脚本,如果不是则在</form>标记之前输出脚本代码</param> public static void AppendScript(string javascript, Page page, bool afterForm) { if (afterForm) { page.ClientScript.RegisterClientScriptBlock(page.GetType(), page.ToString(), javascript); } else { page.ClientScript.RegisterStartupScript(page.GetType(), page.ToString(), javascript); } }
/// <summary> /// 弹出JavaScript小窗口 /// </summary> /// <param name="message">窗口信息</param> /// <param name="page">Page类的实例</param> public static void Alert(string message, Page page) { #region string js = @"<script type='text/javascript'> alert('" + message + "');</script>"; if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "alert")) { page.ClientScript.RegisterStartupScript(page.GetType(), "alert", js); } #endregion }
/// <summary> /// 回到历史页面 /// </summary> /// <param name="value">-1/1</param> public static void GoHistory(int value, Page page) { #region string js = @"<Script type='text/javascript'> history.go({0}); </Script>"; //HttpContext.Current.Response.Write(string.Format(js, value)); if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "GoHistory1")) { page.ClientScript.RegisterStartupScript(page.GetType(), "GoHistory1", string.Format(js, value)); } #endregion }
public static void DoSuccess(string str, bool isClose, Page page) { if (str == "") { str = "操作信息成功!"; } if (isClose) { ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "show", "alert('" + str + "', this);window.close();", true); } else { ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "show", "alert('" + str + "');window.opener.location.reload();window.close();", true); } }
// uso: Util.JQueryUtils.jGrowl(this, "perico"); public static void jGrowl(Page page, string cadena) { page.ClientScript.RegisterClientScriptInclude(page.GetType(), "jquery13", "/JQuery/jGrowl/jquery-1.3.2.js"); page.ClientScript.RegisterClientScriptInclude(page.GetType(), "jquery.jgrowl.js", "/JQuery/jGrowl/jquery.jgrowl.js"); // style .. page.ClientScript.RegisterClientScriptBlock(page.GetType(), "jquery.jgrowl.css", "<link rel=\"stylesheet\" href=\"/JQuery/jGrowl/jquery.jgrowl.css\" />"); StringBuilder sb = new StringBuilder(); sb.Append("$(document).ready(function() {"); sb.Append("$.jGrowl('" + cadena + "');"); sb.Append("});"); page.ClientScript.RegisterClientScriptBlock(page.GetType(), "jQueryScript", sb.ToString(), true); }
public static void PrintWebControl(Control ctrl, string Script) { StringWriter stringWrite = new StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite); if (ctrl is WebControl) { Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w; } Page pg = new Page(); pg.EnableEventValidation = false; pg.StyleSheetTheme = "../CSS/order.css"; if (Script != string.Empty) { pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script); } HtmlLink link = new HtmlLink(); link.Href = "../CSS/order.css"; HtmlForm frm = new HtmlForm(); pg.Controls.Add(frm); frm.Attributes.Add("runat", "server"); frm.Controls.Add(ctrl); pg.DesignerInitialize(); pg.RenderControl(htmlWrite); string strHTML = stringWrite.ToString(); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write("<head runat='server'> <title>Printer - Bản in tại Support.evnit.evn.com.vn</title> <link type='text/css' rel='stylesheet' href='../CSS/order.css'><link type='text/css' rel='stylesheet' href='../CSS/style.css'></head>"); HttpContext.Current.Response.Write(strHTML); HttpContext.Current.Response.Write("<script>window.print();</script>"); HttpContext.Current.Response.End(); }
public static void Alert(Page page, string Msg, string RedirectUrl, string FrameName) { FrameName = FrameName.Trim(); if (!string.IsNullOrEmpty(FrameName)) { FrameName = FrameName + "."; } if (!string.IsNullOrEmpty(RedirectUrl)) { page.ClientScript.RegisterStartupScript(page.GetType(), "", "<Script language=javascript>alert('" + Msg + "');window." + FrameName + "location.replace('" + RedirectUrl + "')</script>"); } else { page.ClientScript.RegisterStartupScript(page.GetType(), "", "<Script language=javascript>alert('" + Msg + "');window." + FrameName + "location.href = window." + FrameName + "location.href</script>"); } }
public void RegisterInitializationScript(Page page, params string[] scripts) { var key = page.GetType().Name; if (_initializationLines.ContainsKey(key)) return; _initializationLines.Add(key, scripts.ToSeparatedString("\r\n")); }
public static void Alert(string Msg,Page page) { page.ClientScript.RegisterStartupScript( page.GetType(), Guid.NewGuid().toString(), string.Format(BaseJs, "alert(\"" + Msg + "\");")); }
/// <summary> /// Loads a CSS file reference onto the page /// to the file at the given url /// with the given CSS media attribute. /// /// The url may be: /// /// 1. An absolute url "http://" or "https://" /// 2. A tilde url "~/" /// 3. A url relative to the given page /// /// The media parameter may be used to give /// the CCS media attribute. The parameter /// is ignored if it is null or empty. /// </summary> /// <param name="page">The page on which to load</param> /// <param name="url">The url of the file</param> /// <param name="media">The CSS media attribute if any</param> public static void LoadFileReference(Page page, string url, string media) { ClientScriptManager clientscriptmanager = page.ClientScript; Type type = page.GetType(); if (!clientscriptmanager.IsClientScriptBlockRegistered(type, url)) { string pageTildePath = FileTools.GetTildePath(page); string resolvedUrl = FileTools.GetResolvedUrl(pageTildePath, url); StringBuilder builder = new StringBuilder(); builder.Append(open_css_link); builder.Append(resolvedUrl); if ((media != null) && (media.Length > 0)) { builder.Append(media_css); builder.Append(media); } builder.Append(shut_css_link); string contents = builder.ToString(); clientscriptmanager.RegisterClientScriptBlock (type, url, contents, false); } }
public static void PrintWebControl(Control ctrl, string Script) { StringWriter stringWrite = new StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite); if (ctrl is WebControl) { Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w; } Page pg = new Page(); pg.EnableEventValidation = false; if (Script != string.Empty) { pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script); } HtmlForm frm = new HtmlForm(); pg.Controls.Add(frm); frm.Attributes.Add("runat", "server"); frm.Controls.Add(ctrl); pg.DesignerInitialize(); pg.RenderControl(htmlWrite); string strHTML = stringWrite.ToString(); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(strHTML); HttpContext.Current.Response.Write("<script>window.print();</script>"); HttpContext.Current.Response.End(); }
public string genera_chart_column_Flash(string DivId, string Sdatos, string sTitulo, Page pagina, Int32 ancho = 600, Int32 alto = 400) { try { Type cstype = pagina.GetType(); ClientScriptManager cs = pagina.ClientScript; StringBuilder sb = new StringBuilder(); sb.AppendLine("var params ={bgcolor: \"#FFFFFF\"}"); sb.AppendLine("var flashVars = { path: \"/AmCharts/flash/\", chart_settings: encodeURIComponent(\"<settings> <thousands_separator>18</thousands_separator><decimals_separator>.</decimals_separator><digits_after_decimal>3</digits_after_decimal><background><alpha>100</alpha><border_alpha>0</border_alpha></background><grid><category><dashed>1</dashed></category><value><dashed>1</dashed></value></grid><axes><category><width>1</width><color>E7E7E7</color></category><value><width>1</width><color>E7E7E7</color></value></axes><values><value><min>0</min></value></values><balloon><alpha>62</alpha></balloon><column><type>clustered</type><width>89</width><alpha>85</alpha><border_alpha>95</border_alpha><balloon_text><![CDATA[En {series} {percents}% de las mejoras están {title}</b>]]></balloon_text><grow_time>3</grow_time><sequenced_grow>1</sequenced_grow></column><depth>15</depth><graphs><graph gid='0'><title>Medicion Inicial</title><color>e0081d</color></graph><graph gid='1'><title>Medicion Final</title><color>005ea7</color></graph><graph gid='2'><title>Line</title><color>FEC514</color></graph></graphs><labels><label lid='0'><text><![CDATA[<b>" + sTitulo + "</b>]]></text><y>18</y><text_color>000000</text_color><text_size>13</text_size><align>center</align></label></labels></settings>\") "); sb.AppendLine(", chart_data: encodeURIComponent(\"" + Sdatos + "\") };"); sb.AppendLine("window.onload = function () {"); sb.AppendLine(" if (swfobject.hasFlashPlayerVersion(\"8\")) {swfobject.embedSWF(\"/AmCharts/flash/amcolumn.swf?cache=0\", \"" + DivId + "\", \"" + ancho + "\", \"" + alto + "\", \"8.0.0\", \"/AmCharts/flash/expressInstall.swf\", flashVars, params);"); sb.AppendLine(" }else {"); sb.AppendLine(" var amFallback = new AmCharts.AmFallback();"); sb.AppendLine(" amFallback.pathToImages = \"/AmCharts/javascript/images/\";"); sb.AppendLine(" amFallback.type = \"column\";"); sb.AppendLine(" amFallback.write(\"" + DivId + "\");"); sb.AppendLine(" }"); sb.AppendLine("}"); if ((cs.IsStartupScriptRegistered(DivId) == false)) { cs.RegisterStartupScript(cstype, DivId, sb.ToString(), true); } return ""; } catch (Exception ex) { return "<span>" + ex.Message + "</span>"; } }
public string genera_chart_line_Flash(string DivId, string Sdatos, string sTitulo, string Graphs, Page pagina, Int32 ancho = 600, Int32 alto = 400) { try { Type cstype = pagina.GetType(); ClientScriptManager cs = pagina.ClientScript; StringBuilder sb = new StringBuilder(); sb.AppendLine("var params ={bgcolor: \"#FFFFFF\"}"); sb.AppendLine("var flashVars = { path: \"amcharts/flash/\", chart_settings: encodeURIComponent(\"<settings><text_color>oooooo</text_color><digits_after_decimal>2</digits_after_decimal><background><file></file></background><plot_area><margins><left>0</left><right>0</right><top>15</top></margins></plot_area><grid><x><alpha>0</alpha><approx_count>10</approx_count></x><y_left><color>FFFFF1</color><alpha>10</alpha></y_left></grid><axes><x><width>1</width><color>FFFFFF</color><alpha>0</alpha></x><y_left><width>1</width><alpha>0</alpha></y_left></axes><values><x><skip_first>1</skip_first><skip_last>1</skip_last></x><y_left><inside>1</inside><skip_last>1</skip_last><unit></unit><unit_position>left</unit_position></y_left></values><scroller><height>15</height><color>000000</color><alpha>30</alpha><bg_color>FFFFFF</bg_color><bg_alpha>20</bg_alpha></scroller><indicator><selection_color>000000</selection_color></indicator><legend><alpha>20</alpha><margins>15</margins><align>center</align><values><enabled>1</enabled><text>{value}</text></values></legend><zoom_out_button><alpha>100</alpha><text_color>FFFFFF</text_color><text_color_hover>000000</text_color_hover></zoom_out_button><graphs>" + Graphs + "</graphs><export_as_image><file>amcharts/flash/export.aspx</file><color>#CC0000</color><alpha>50</alpha></export_as_image><labels><label lid='0'><text><![CDATA[<b>" + sTitulo + "</b>]]></text><y>5</y><text_size>15</text_size><align>center</align></label></labels></settings>\") "); sb.AppendLine(", chart_data: encodeURIComponent(\"" + Sdatos + "\") };"); sb.AppendLine("window.onload = function () {"); sb.AppendLine(" if (swfobject.hasFlashPlayerVersion(\"8\")) {swfobject.embedSWF(\"amcharts/flash/amline.swf?cache=0\", \"" + DivId + "\", \"" + ancho + "\", \"" + alto + "\", \"8.0.0\", \"amcharts/flash/expressInstall.swf\", flashVars, params);"); sb.AppendLine(" }else {"); sb.AppendLine(" var amFallback = new AmCharts.AmFallback();"); sb.AppendLine(" amFallback.pathToImages = \"amcharts/javascript/images/\";"); sb.AppendLine(" amFallback.type = \"line\";"); sb.AppendLine(" amFallback.write(\"" + DivId + "\");"); sb.AppendLine(" }"); sb.AppendLine("}"); if ((cs.IsStartupScriptRegistered(DivId) == false)) { cs.RegisterStartupScript(cstype, DivId, sb.ToString(), true); } return ""; } catch (Exception ex) { return "<span>" + ex.Message + "</span>"; } }
/// <summary> /// Loads a Javascript file reference onto the page /// to the file at the given url. /// /// The url may be: /// /// 1. An absolute url "http://" or "https://" /// 2. A tilde url "~/" /// 3. A url relative to the given page /// /// </summary> /// <param name="page">The page on which to load</param> /// <param name="url">The url of the file</param> public static void LoadFileReference(Page page, string url) { ClientScriptManager clientscriptmanager = page.ClientScript; Type type = page.GetType(); if (!clientscriptmanager.IsClientScriptBlockRegistered(type, url)) { string pageTildePath = FileTools.GetTildePath(page); string resolvedUrl = FileTools.GetResolvedUrl(pageTildePath, url); StringBuilder builder = new StringBuilder(); builder.Append(script_file_1); builder.Append(resolvedUrl); builder.Append(script_file_2); string contents = builder.ToString(); clientscriptmanager.RegisterClientScriptBlock (type, url, contents, false); } }
public static void AddScriptToHeader(string key, string src, Page page) { if (page.Header != null) { if (!page.ClientScript.IsClientScriptBlockRegistered(page.GetType(), key)) { page.ClientScript.RegisterClientScriptBlock(page.GetType(), key, String.Empty); ((HtmlHead)page.Header).Controls.Add(new LiteralControl(String.Format("<script type=\"text/javascript\" src=\"{0}\"></script>", src))); } } else { // can't add to header, will failback to a simple register script page.ClientScript.RegisterClientScriptBlock(page.GetType(), key, String.Format("<script type=\"text/javascript\" src=\"{0}\"></script>", src)); } }
public static void AddLinkToHeader(string key, string src, Page page) { if (page.Header != null) { if (!page.ClientScript.IsClientScriptBlockRegistered(page.GetType(), key)) { page.ClientScript.RegisterClientScriptBlock(page.GetType(), key, String.Empty); ((HtmlHead)page.Header).Controls.Add(new LiteralControl(String.Format("<link rel=\"stylesheet\" href=\"{0}\" />", src))); } } else { // can't add to header, will failback to a simple register script page.ClientScript.RegisterClientScriptBlock(page.GetType(), key, String.Format("<link rel=\"stylesheet\" href=\"{0}\" />", src)); } }
public static void HideModal(Control control, Page pageObject, string modalId) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#" + modalId + "').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(control, pageObject.GetType(), Guid.NewGuid().ToString(), sb.ToString(), false); }
public static void RegisterConfirmScript(string message, string YesNavigateTo, string NoNavigateTo, string key, Page page) { string script = @"if(confirm('" + message + @"')) window.href='" + YesNavigateTo + @"'); else window.href='" + NoNavigateTo + @"')"; page.ClientScript.RegisterClientScriptBlock(page.GetType(), page.UniqueID + key, script, true); }
public static void PopupErrore(Page page, string messaggio = "") { if (string.IsNullOrWhiteSpace(messaggio)) { messaggio = "Errore"; } page.ClientScript.RegisterStartupScript(page.GetType(), "alertResult", "alert('" + messaggio + "');", true); }
/// <summary> /// Ajax启动脚本 For 引用AJAX组件的页 /// 弹出对话框并跳转到URL页 /// </summary> /// <param name="page">一般是this</param> /// <param name="msg">对话框提示串</param> /// <param name="url">跳往的地址</param> public static void AjaxAlertAndLocationHref(System.Web.UI.Page page, string msg, string url) { page.ClientScript.RegisterStartupScript(page.GetType(), "ajaxjs", string.Format("alert('{0}!');location.href='{1}';", msg, url), true); }
private static void AddJavaScript(string src, Page page) { page.ClientScript.RegisterStartupScript(page.GetType(), src, String.Format("<script type=\"text/javascript\" src=\"{0}\"></script>", GetUrl(ScriptsFolder(), src))); }
/// <summary> /// 消息框 /// </summary> /// <param name="page">Page</param> /// <param name="message">提示信息</param> static public void MessageBox(System.Web.UI.Page page, string message) { page.Page.ClientScript.RegisterStartupScript(page.GetType(), "", "<script>window.alert('" + message + "')</script>"); }
/// <summary> /// 往前端注册一段javascript /// </summary> public static void RegisterJS(System.Web.UI.Page page, string javascript) { page.ClientScript.RegisterStartupScript(page.GetType(), "", "$(function(){" + javascript + ";});", true); }
/// <summary> /// Ajax启动脚本 For 引用AJAX组件的页 /// AjaxAlert:弹出对话框 /// </summary> /// <param name="page">一般是this</param> /// <param name="msg">对话框提示串</param> public static void AjaxAlert(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "ajaxjs", string.Format("alert('{0}!')", msg), true); }
protected void btnSubmit_Click(object sender, EventArgs e) { // 记录其IP地址,下次登录时验证,IP为空则记录,IP不为空则验证 string uname = this.txtUserName.Text.Trim(); string upwd = this.txtUserPwd.Text.Trim(); string code = txtCode.Text.Trim(); if (uname.Equals("") || upwd.Equals("")) { lblTip.Visible = true; lblTip.Text = "请输入用户名或密码"; return; } if (code.Equals("")) { lblTip.Visible = true; lblTip.Text = "请输入验证码"; return; } if (Session[verify_code.SESSION_CODE] == null) { lblTip.Visible = true; lblTip.Text = "系统找不到验证码"; return; } if (code.ToLower() != Session[verify_code.SESSION_CODE].ToString().ToLower()) { lblTip.Visible = true; lblTip.Text = "验证码输入不正确"; return; } string uid = new Daiv_OA.BLL.UserBLL().Existslongin(uname, Daiv_OA.Utils.MD5.Lower32(upwd)); if (uid != "") { Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(int.Parse(uid)); if (model.Uipaddress != "") { if (model.Uipaddress != Page.Request.UserHostAddress) { Response.Write("<script>alert('非法IP,请在本机登陆!');</script>"); Response.End(); } } int iExpires = 0; //设置Cookies //System.Collections.Specialized.NameValueCollection myCol = new System.Collections.Specialized.NameValueCollection(); //myCol.Add("id", uid.ToString()); //myCol.Add("name", uname); //myCol.Add("ip", Request.UserHostAddress); //new BLL.UserBLL().UpdateTime(model.Uid); int pid = model.Pid; //myCol.Add("Powerid", pid.ToString()); //Daiv_OA.Utils.Cookie.SetObj("oa_user", 60 * 60 * 15 * iExpires, myCol, "", "/"); new BLL.UserBLL().SetUserCookies(model, Request.UserHostAddress, iExpires); switch (pid) { case 1: Session["UserName"] = uname; Response.Redirect("Index.aspx"); //管理员 break; case 2: Session["UserName"] = uname; Response.Redirect("Index.aspx"); //管理组织层 break; case 3: Session["UserName"] = uname; Response.Redirect("Index.aspx"); //网站编辑 break; case 4: Session["UserName"] = uname; Response.Redirect("Index.aspx"); //美工和程序员 break; } } else { this.txtUserName.Text = ""; this.txtUserPwd.Text = ""; System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler; page.ClientScript.RegisterStartupScript(page.GetType(), "clientScript", "<script language='javascript'>alert('请正确填写用户名和密码!');</script>"); } }
public static void Alert(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script type='text/javascript'>alert('" + msg.ToString() + "');</script>"); }
/// <summary> /// 显示方法 /// </summary> /// <param name="page">当前页面指针,一般为this</param> /// <param name="msg">方法信息</param> public static void ShowFunction(System.Web.UI.Page page, string function) { page.ClientScript.RegisterStartupScript(page.GetType(), "function", "<script language='javascript' defer>" + function.ToString() + "</script>"); }
/// <summary> /// ����Զ���ű���Ϣ /// </summary> /// <param name="page">��ǰҳ��ָ�룬һ��Ϊthis</param> /// <param name="script">����ű�</param> public static void ResponseScript(System.Web.UI.Page page, string script) { page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>" + script + "</script>"); }
/// <summary> /// ��ʾ��Ϣ��ʾ�Ի�������ҳ����ת /// </summary> /// <param name="page">��ǰҳ��ָ�룬һ��Ϊthis</param> /// <param name="msg">��ʾ��Ϣ</param> /// <param name="url">��ת��Ŀ��URL</param> public static void ShowAndRedirect(System.Web.UI.Page page, string msg, string url) { //Response.Write("<script>alert('�ʻ����ͨ��������ȥΪ��ҵ��ֵ��');window.location=\"" + pageurl + "\"</script>"); page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>alert('" + msg + "');window.location=\"" + url + "\"</script>"); }
/// <summary> /// ��ʾ��Ϣ��ʾ�Ի��� /// </summary> /// <param name="page">��ǰҳ��ָ�룬һ��Ϊthis</param> /// <param name="msg">��ʾ��Ϣ</param> public static void Show(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>alert('" + msg.ToString() + "');</script>"); }
/// <summary> /// 显示操作失败的提示信息 /// </summary> /// <param name="page"></param> /// <param name="msg"></param> public static void ShowFailTip(System.Web.UI.Page page, string msg, string url) { page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>ShowFailTip('" + msg + "');function jump(count){window.setTimeout(function(){count--;if(count>0){jump(count)}else{window.location.href=\"" + url + "\"}},1000)}jump(1);</script>"); }
public static void ShowMessageBox(System.Web.UI.Page page, string message) { page.ClientScript.RegisterStartupScript(page.GetType(), "msgbox", "<script>alert('" + message + "');</script>"); }
/// <summary> /// 弹出对话框,刷新本页 /// </summary> /// <param name="page"></param> /// <param name="msg"></param> public static void ShowRefresh(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "message2", "<script language='javascript' defer>alert('" + msg.ToString() + "');window.location.href=window.location.href;</script>"); }
public void MessageBoxShowClose(string value, System.Web.UI.Page page) { ClientScriptManager CSM = page.ClientScript; CSM.RegisterStartupScript(page.GetType(), "", "<script>alert('" + value + "'); window.close();</script>"); }
/// <summary> /// Ajax启动脚本 For 引用AJAX组件的页 /// JS语句 /// </summary> /// <param name="page">一般是this</param> /// <param name="js">如alert('test');</param> public static void AjaxEndRunJs(System.Web.UI.Page page, string js) { page.ClientScript.RegisterClientScriptBlock(page.GetType(), "ajaxjs", string.Format("{0}", js), true); }
/// <summary> ///并进行页面跳转 /// </summary> /// <param name="page">当前页面指针,一般为this</param> /// <param name="url">跳转的目标URL</param> public static void Redirect(System.Web.UI.Page page, string url) { page.ClientScript.RegisterStartupScript(page.GetType(), "", "<script language='javascript' defer>window.location=\"" + url + "\"</script>"); }
public static void Dialog(string cType, string Code) { System.Web.UI.Page Page = HttpContext.Current.Handler as System.Web.UI.Page; Page.ClientScript.RegisterStartupScript(Page.GetType(), cType, Code, true); }
private static void AddOptions(Page page) { StringBuilder sb = new StringBuilder(); var executeOn = @" if (typeof executeOn === 'undefined') { window.executeOn = function (condition, func) { var interval = setInterval(function () { try { var result = false; if (typeof condition === ""function"") { result = condition(); } else if (typeof condition === ""string"") { result = eval(condition); } else { throw ""argument 'condition' must be a bool function or a bool expression.""; } if (result === true) { clearInterval(interval); func(); } } catch (ex) { clearInterval(interval); throw ex; } }, 100); }; }"; sb.AppendLine("<script type=\"text/javascript\" defer=\"defer\">"); sb.AppendLine(executeOn); sb.AppendLine(@"executeOn(""typeof SyntaxHighlighter !== 'undefined' "", function() {"); // add not-default options if (Options != null) { if (Options.GetSingleValue("gutter").ToLowerInvariant() == "false") { sb.AppendLine(GetOption("gutter")); } if (Options.GetSingleValue("smart-tabs").ToLowerInvariant() == "false") { sb.AppendLine(GetOption("smart-tabs")); } if (Options.GetSingleValue("auto-links").ToLowerInvariant() == "false") { sb.AppendLine(GetOption("auto-links")); } if (Options.GetSingleValue("collapse").ToLowerInvariant() == "true") { sb.AppendLine(GetOption("collapse")); } if (Options.GetSingleValue("toolbar").ToLowerInvariant() == "false") { sb.AppendLine(GetOption("toolbar")); } if (Options.GetSingleValue("tab-size") != "4") { sb.AppendLine(GetOption("tab-size")); } } //sb.AppendLine("\tSyntaxHighlighter.all();"); sb.AppendLine(@" executeOn(""document.readyState === 'loaded' || document.readyState === 'complete'"", function() { SyntaxHighlighter.all(); });"); sb.AppendLine(@"});"); sb.AppendLine("</script>"); page.ClientScript.RegisterStartupScript(page.GetType(), "SyntaxHighlighter", sb.ToString(), false); }
public static void MessageBox(System.Web.UI.Page page, string strMsg) { //+ character added after strMsg "')" ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "alertMessage", "alert('" + strMsg + "')", true); }
/// <summary> /// 前端提示消息注册 /// </summary> /// <param name="page"></param> /// <param name="alert"></param> public static void alert(System.Web.UI.Page page, string alert) { page.ClientScript.RegisterStartupScript(page.GetType(), "", "$(function(){alert('" + alert + "');});", true); }
public static void ClientAlert(System.Web.UI.Page page, string message) { page.ClientScript.RegisterStartupScript(page.GetType(), "alert", "alert('" + message + "');", true); }
/// <summary> /// 返回 /// </summary> /// <param name="page">Page</param> static public void GoBack(System.Web.UI.Page page) { page.Page.ClientScript.RegisterStartupScript(page.GetType(), "ck1", "history.go(-1);", true); }
/// <summary> /// 初始化PageCtrl,在Page的Page_Load函数里被调用 /// </summary> public void Page_Load(System.Web.UI.Page _page, Control ParentControl) { page = _page; LinkButton_FirstPage.Text = "首页"; LinkButton_Pre.Text = "上一页"; LinkButton_Next.Text = "下一页"; LinkButton_LastPage.Text = "尾页"; Label_CurPageText.Text = "当前页:"; Label_CurPage.Text = "0"; Label_TotalPageText.Text = ", 总页数:"; Label_TotalPage.Text = "0"; List_PageItemCount.Items.Add(new ListItem("每页10条", "10")); List_PageItemCount.Items.Add(new ListItem("每页20条", "20")); List_PageItemCount.Items.Add(new ListItem("每页30条", "30")); List_PageItemCount.Items.Add(new ListItem("每页40条", "40")); List_PageItemCount.Items.Add(new ListItem("每页50条", "50")); List_PageItemCount.Items.Add(new ListItem("每页100条", "100")); List_PageItemCount.Items.Add(new ListItem("每页200条", "200")); List_PageItemCount.Items.Add(new ListItem("每页500条", "500")); List_PageItemCount.Items.Add(new ListItem("每页1000条", "1000")); List_PageItemCount.SelectedIndex = 5; List_PageItemCount.AutoPostBack = true; orderField.ID = "orderField"; orderMode.ID = "orderMode"; LinkButton_FirstPage.CssClass = "PageCtrl"; LinkButton_Pre.CssClass = "PageCtrl"; LinkButton_Next.CssClass = "PageCtrl"; LinkButton_LastPage.CssClass = "PageCtrl"; LinkButton_FirstPage.Click += new EventHandler(OnFirst); LinkButton_Pre.Click += new EventHandler(OnPre); LinkButton_Next.Click += new EventHandler(OnNext); LinkButton_LastPage.Click += new EventHandler(OnLast); List_PageItemCount.SelectedIndexChanged += new EventHandler(OnPageCountChanged); ParentControl.Controls.Add(LinkButton_FirstPage); ParentControl.Controls.Add(LinkButton_Pre); ParentControl.Controls.Add(LinkButton_Next); ParentControl.Controls.Add(LinkButton_LastPage); ParentControl.Controls.Add(List_PageItemCount); ParentControl.Controls.Add(Label_CurPageText); ParentControl.Controls.Add(Label_CurPage); ParentControl.Controls.Add(Label_TotalPageText); ParentControl.Controls.Add(Label_TotalPage); ParentControl.Controls.Add(orderField); ParentControl.Controls.Add(orderMode); page.LoadComplete += new EventHandler(OnLoadComplete); page.PreRenderComplete += new EventHandler(OnPreRenderComplete); Type cstype = page.GetType(); ClientScriptManager cs = page.ClientScript; string strCheckInput = @"<script type='text/javascript'>$(function(){ var ths = $('thead th') ths.click(function(){ var szID = $(this).attr('id'); if(!szID || szID == '') { return; } if(__doPostBack) { __doPostBack('ChangePageOrder',szID); } }); ths.html(function(nindex,szhtml){ var thisID = $(this).attr('id'); if(thisID != null && thisID != '') { if(thisID == $('#orderField').val()) { if($('#orderMode').val() == 'asc') { return '<div class=\'canOrder\'><img src=\'UI_themes/images/icons/list_px_up.gif\'/>' + szhtml+'</div>'; //当前排序行,正序 }else{ return '<div class=\'canOrder\'><img src=\'UI_themes/images/icons/list_px_down.gif\'/>' + szhtml+'</div>'; //当前排序行,侄序 } }else{ return '<div class=\'canOrder\'><img src=\'UI_themes/images/icons/list_px.gif\'/>' + szhtml+'</div>'; //可排序行 } }else{ return szhtml; //不能排序行,原样输出 } }); });</script>"; if (!cs.IsStartupScriptRegistered(cstype, "PageCtrl_tableInit")) { cs.RegisterStartupScript(cstype, "PageCtrl_tableInit", strCheckInput); } }
public static void CreateMessageAlert(System.Web.UI.Page senderPage, string alertMsg, string alertKey) { ScriptManager.RegisterStartupScript(senderPage, senderPage.GetType(), alertKey, "alert('" + alertMsg + "');", true); }
/// <summary> /// Ajax启动脚本 For 引用AJAX组件的页 /// 转向到新的URL /// </summary> /// <param name="page">一般是this</param> /// <param name="toURL">连接地址</param> public static void AjaxRedirect(System.Web.UI.Page page, string toURL) { #region page.ClientScript.RegisterStartupScript(page.GetType(), "ajaxjs", string.Format("window.location.replace('{0}');", toURL), true); #endregion }
public static void MessageBox(System.Web.UI.Page aPage, System.String Msg) { ScriptManager.RegisterStartupScript(aPage, aPage.GetType(), Guid.NewGuid().ToString(), "alert('" + Msg + "');", true); }
public static void NovaJanela(System.Web.UI.Page aPage, System.String URL) { ScriptManager.RegisterStartupScript(aPage, aPage.GetType(), Guid.NewGuid().ToString(), "window.open('" + URL + "','Link','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=800,height=600,left=0,top=0');", true); }
/// <summary> /// 执行制定的js脚本 /// </summary> /// <param name="code">js脚本</param> /// <param name="page">page类</param> public static void exec(string code) { System.Web.UI.Page page = (System.Web.UI.Page)HttpContext.Current.Handler; page.ClientScript.RegisterStartupScript(page.GetType(), "", "<script type=\"text/javascript\" defer=\"defer\">" + code + "</script>"); }
public static void ShowAlert(System.Web.UI.Page page, string message) { page.ClientScript.RegisterStartupScript(page.GetType(), DateTime.Now.ToString(), "alert(\"" + message + "\");", true); }