using System;
|
using System.Web;
|
using System.Web.UI.HtmlControls ;
|
using System.Web.UI;
|
|
/// <summary>
|
/// ÌṩÏòÒ³ÃæÊä³ö¿Í»§¶Ë´úÂëʵÏÖÌØÊ⹦Äܵķ½·¨
|
/// </summary>
|
/// <remarks>
|
/// </remarks>
|
|
public class JScript
|
{
|
public static void AlertAndRedirect(string message,string toURL)
|
{
|
string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
|
HttpContext.Current.Response.Write(string.Format(js,message ,toURL));
|
}
|
/// <summary>
|
/// Ïò¿Í»§¶Ë·¢Ëͺ¯ÊýKendoPostBack(eventTarget, eventArgument)
|
/// ·þÎñÆ÷¶Ë¿É½ÓÊÕ__EVENTTARGET,__EVENTARGUMENTµÄÖµ
|
/// </summary>
|
/// <param name="page">System.Web.UI.Page Ò»°ãΪthis</param>
|
public static void JscriptSender(System.Web.UI.Page page)
|
{
|
|
// page.RegisterHiddenField("__EVENTTARGET","");
|
// page.RegisterHiddenField("__EVENTARGUMENT","");
|
// string s = @"
|
//<script language=Javascript>
|
// function KendoPostBack(eventTarget, eventArgument)
|
// {
|
// var theform = document.forms[0];
|
// theform.__EVENTTARGET.value = eventTarget;
|
// theform.__EVENTARGUMENT.value = eventArgument;
|
// theform.submit();
|
// }
|
//</script>";
|
|
// page.RegisterStartupScript("sds",s);
|
}
|
/// <summary>
|
/// µ¯³öJavaScriptС´°¿Ú
|
/// </summary>
|
/// <param name="js">´°¿ÚÐÅÏ¢</param>
|
public static void Alert(string message)
|
{
|
message = StringUtil.DeleteUnVisibleChar(message);
|
string js=@"<Script language='JavaScript'>
|
alert('"+ message +"');</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
public static void Alert(object message)
|
{
|
string js=@"<Script language='JavaScript'>
|
alert('{0}');
|
</Script>";
|
HttpContext.Current.Response.Write(string.Format(js,message.ToString()));
|
}
|
|
public static void RtnRltMsgbox(object message,string strWinCtrl)
|
{
|
string js = @"<Script language='JavaScript'>
|
strWinCtrl = true;
|
strWinCtrl = if(!confirm('"+ message +"'))return false;</Script>";
|
HttpContext.Current.Response.Write(string.Format(js,message.ToString()));
|
}
|
|
/// <summary>
|
/// »Øµ½ÀúÊ·Ò³Ãæ
|
/// </summary>
|
/// <param name="value">-1/1</param>
|
public static void GoHistory(int value)
|
{
|
string js=@"<Script language='JavaScript'>
|
history.go({0});
|
</Script>";
|
HttpContext.Current.Response.Write(string.Format(js,value));
|
}
|
|
/// <summary>
|
/// ¹Ø±Õµ±Ç°´°¿Ú
|
/// </summary>
|
public static void CloseWindow()
|
{
|
string js=@"<Script language='JavaScript'>
|
window.close();
|
</Script>";
|
HttpContext.Current.Response.Write(js);
|
HttpContext.Current.Response.End();
|
}
|
|
/// <summary>
|
/// ˢи¸´°¿Ú
|
/// </summary>
|
public static void RefreshParent()
|
{
|
string js=@"<Script language='JavaScript'>
|
parent.location.reload();
|
</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
/// ¸ñʽ»¯ÎªJS¿É½âÊ͵Ä×Ö·û´®
|
/// </summary>
|
/// <param name="s"></param>
|
/// <returns></returns>
|
public static string JSStringFormat(string s)
|
{
|
return s.Replace("\r","\\r").Replace("\n","\\n").Replace("'","\\'").Replace("\"","\\\"");
|
}
|
|
/// <summary>
|
/// ˢдò¿ª´°¿Ú
|
/// </summary>
|
public static void RefreshOpener()
|
{
|
string js=@"<Script language='JavaScript'>
|
opener.location.reload();
|
</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
/// ´ò¿ª´°¿Ú
|
/// </summary>
|
/// <param name="url"></param>
|
public static void OpenWebForm(string url)
|
{
|
|
/*¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡*/
|
/*ÐÞ¸ÄÈËÔ±: sxs */
|
/*ÐÞ¸Äʱ¼ä: 2003-4-9 */
|
/*ÐÞ¸ÄÄ¿µÄ: пªÒ³ÃæÈ¥µôieµÄ²Ëµ¥¡£¡£¡£ */
|
/*×¢ÊÍÄÚÈÝ: */
|
/*¿ªÊ¼*/
|
string js=@"<Script language='JavaScript'>
|
//window.open('"+url+@"');
|
window.open('"+url+@"','','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');
|
</Script>";
|
/*½áÊø*/
|
/*¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡*/
|
|
|
HttpContext.Current.Response.Write(js);
|
}
|
public static void OpenWebForm(string url,string name,string future)
|
{
|
string js=@"<Script language='JavaScript'>
|
window.open('"+url+@"','"+name+@"','"+future+@"')
|
</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
public static void OpenWebForm(string url,string formName)
|
{
|
/*¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡*/
|
/*ÐÞ¸ÄÈËÔ±: sxs */
|
/*ÐÞ¸Äʱ¼ä: 2003-4-9 */
|
/*ÐÞ¸ÄÄ¿µÄ: пªÒ³ÃæÈ¥µôieµÄ²Ëµ¥¡£¡£¡£ */
|
/*×¢ÊÍÄÚÈÝ: */
|
/*¿ªÊ¼*/
|
string js=@"<Script language='JavaScript'>
|
//window.open('"+url+@"','"+formName+@"');
|
window.open('"+url+@"','"+formName+@"','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');
|
</Script>";
|
/*½áÊø*/
|
/*¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡*/
|
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
/// º¯ÊýÃû:OpenWebForm
|
/// ¹¦ÄÜÃèÊö:´ò¿ªWEB´°¿Ú
|
/// ´¦ÀíÁ÷³Ì:
|
/// Ëã·¨ÃèÊö:
|
/// ×÷ Õß: Ëïºé±ë
|
/// ÈÕ ÆÚ: 2003-04-29 17:00
|
/// ÐÞ ¸Ä:
|
/// ÈÕ ÆÚ:
|
/// °æ ±¾:
|
/// </summary>
|
/// <param name="url">WEB´°¿Ú</param>
|
/// <param name="isFullScreen">ÊÇ·ñÈ«ÆÁÄ»</param>
|
public static void OpenWebForm(string url,bool isFullScreen)
|
{
|
string js=@"<Script language='JavaScript'>";
|
if(isFullScreen)
|
{
|
js+="var iWidth = 0;";
|
js+="var iHeight = 0;";
|
js+="iWidth=window.screen.availWidth-10;";
|
js+="iHeight=window.screen.availHeight-50;";
|
js+="var szFeatures ='width=' + iWidth + ',height=' + iHeight + ',top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no';";
|
js+="window.open('"+url+@"','',szFeatures);";
|
}
|
else
|
{
|
js+="window.open('"+url+@"','','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');";
|
}
|
js+="</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
/// <summary>
|
/// תÏòUrlÖÆ¶¨µÄÒ³Ãæ
|
/// </summary>
|
/// <param name="url"></param>
|
public static void JavaScriptLocationHref(string url)
|
{
|
string js=@"<Script language='JavaScript'>
|
window.location.replace('{0}');
|
</Script>";
|
js=string.Format(js,url);
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
/// Ö¸¶¨µÄ¿ò¼ÜÒ³Ãæ×ª»»
|
/// </summary>
|
/// <param name="FrameName"></param>
|
/// <param name="url"></param>
|
public static void JavaScriptFrameHref(string FrameName,string url)
|
{
|
string js=@"<Script language='JavaScript'>
|
|
@obj.location.replace(""{0}"");
|
</Script>";
|
js = js.Replace("@obj",FrameName );
|
js=string.Format(js,url);
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
///ÖØÖÃÒ³Ãæ
|
/// </summary>
|
public static void JavaScriptResetPage(string strRows)
|
{
|
string js=@"<Script language='JavaScript'>
|
window.parent.CenterFrame.rows='"+strRows+"';</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
/// <summary>
|
/// º¯ÊýÃû:JavaScriptSetCookie
|
/// ¹¦ÄÜÃèÊö:¿Í»§¶Ë·½·¨ÉèÖÃCookie
|
/// ×÷Õß:sxs
|
/// ÈÕÆÚ£º2003-4-9
|
/// °æ±¾£º1.0
|
/// </summary>
|
/// <param name="strName">CookieÃû</param>
|
/// <param name="strValue">CookieÖµ</param>
|
public static void JavaScriptSetCookie(string strName,string strValue)
|
{
|
string js=@"<script language=Javascript>
|
var the_cookie = '"+strName+"="+strValue+@"'
|
var dateexpire = 'Tuesday, 01-Dec-2020 12:00:00 GMT';
|
//document.cookie = the_cookie;//дÈëCookie<BR>} <BR>
|
document.cookie = the_cookie + '; expires='+dateexpire;
|
</script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
/// º¯ÊýÃû:GotoParentWindow
|
/// ¹¦ÄÜÃèÊö:·µ»Ø¸¸´°¿Ú
|
/// ´¦ÀíÁ÷³Ì:
|
/// Ëã·¨ÃèÊö:
|
/// ×÷ Õß: Ëïºé±ë
|
/// ÈÕ ÆÚ: 2003-04-30 10:00
|
/// ÐÞ ¸Ä:
|
/// ÈÕ ÆÚ:
|
/// °æ ±¾:
|
/// </summary>
|
/// <param name="parentWindowUrl">¸¸´°¿Ú</param>
|
public static void GotoParentWindow(string parentWindowUrl)
|
{
|
string js=@"<Script language='JavaScript'>
|
this.parent.location.replace('"+parentWindowUrl+"');</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
/// º¯ÊýÃû:ReplaceParentWindow
|
/// ¹¦ÄÜÃèÊö:Ìæ»»¸¸´°¿Ú
|
/// ´¦ÀíÁ÷³Ì:
|
/// Ëã·¨ÃèÊö:
|
/// ×÷ Õß: Ëïºé±ë
|
/// ÈÕ ÆÚ: 2003-04-30 10:00
|
/// ÐÞ ¸Ä:
|
/// ÈÕ ÆÚ:
|
/// °æ ±¾:
|
/// </summary>
|
/// <param name="parentWindowUrl">¸¸´°¿Ú</param>
|
/// <param name="caption">´°¿ÚÌáʾ</param>
|
/// <param name="future">´°¿ÚÌØÕ÷²ÎÊý</param>
|
public static void ReplaceParentWindow(string parentWindowUrl,string caption,string future)
|
{
|
string js="";
|
if(future!=null&&future.Trim()!="")
|
{
|
js=@"<script language=javascript>this.parent.location.replace('"+parentWindowUrl+"','"+caption+"','"+future+"');</script>";
|
}
|
else
|
{
|
js=@"<script language=javascript>var iWidth = 0 ;var iHeight = 0 ;iWidth=window.screen.availWidth-10;iHeight=window.screen.availHeight-50;
|
var szFeatures = 'dialogWidth:'+iWidth+';dialogHeight:'+iHeight+';dialogLeft:0px;dialogTop:0px;center:yes;help=no;resizable:on;status:on;scroll=yes';this.parent.location.replace('"+parentWindowUrl+"','"+caption+"',szFeatures);</script>";
|
}
|
|
HttpContext.Current.Response.Write(js);
|
}
|
|
|
/// <summary>
|
/// º¯ÊýÃû:ReplaceOpenerWindow
|
/// ¹¦ÄÜÃèÊö:Ìæ»»µ±Ç°´°ÌåµÄ´ò¿ª´°¿Ú
|
/// ´¦ÀíÁ÷³Ì:
|
/// Ëã·¨ÃèÊö:
|
/// ×÷ Õß: Ëïºé±ë
|
/// ÈÕ ÆÚ: 2003-04-30 16:00
|
/// ÐÞ ¸Ä:
|
/// ÈÕ ÆÚ:
|
/// °æ ±¾:
|
/// </summary>
|
/// <param name="openerWindowUrl">µ±Ç°´°ÌåµÄ´ò¿ª´°¿Ú</param>
|
public static void ReplaceOpenerWindow(string openerWindowUrl)
|
{
|
string js=@"<Script language='JavaScript'>
|
window.opener.location.replace('"+openerWindowUrl+"');</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
/// º¯ÊýÃû:ReplaceOpenerParentWindow
|
/// ¹¦ÄÜÃèÊö:Ìæ»»µ±Ç°´°ÌåµÄ´ò¿ª´°¿ÚµÄ¸¸´°¿Ú
|
/// ´¦ÀíÁ÷³Ì:
|
/// Ëã·¨ÃèÊö:
|
/// ×÷ Õß: Ëïºé±ë
|
/// ÈÕ ÆÚ: 2003-07-03 19:00
|
/// ÐÞ ¸Ä:
|
/// ÈÕ ÆÚ:
|
/// °æ ±¾:
|
/// </summary>
|
/// <param name="openerWindowUrl">µ±Ç°´°ÌåµÄ´ò¿ª´°¿ÚµÄ¸¸´°¿Ú</param>
|
public static void ReplaceOpenerParentFrame(string frameName,string frameWindowUrl)
|
{
|
string js=@"<Script language='JavaScript'>
|
window.opener.parent." + frameName + ".location.replace('"+frameWindowUrl+"');</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
/// º¯ÊýÃû:ReplaceOpenerParentWindow
|
/// ¹¦ÄÜÃèÊö:Ìæ»»µ±Ç°´°ÌåµÄ´ò¿ª´°¿ÚµÄ¸¸´°¿Ú
|
/// ´¦ÀíÁ÷³Ì:
|
/// Ëã·¨ÃèÊö:
|
/// ×÷ Õß: Ëïºé±ë
|
/// ÈÕ ÆÚ: 2003-07-03 19:00
|
/// ÐÞ ¸Ä:
|
/// ÈÕ ÆÚ:
|
/// °æ ±¾:
|
/// </summary>
|
/// <param name="openerWindowUrl">µ±Ç°´°ÌåµÄ´ò¿ª´°¿ÚµÄ¸¸´°¿Ú</param>
|
public static void ReplaceOpenerParentWindow(string openerParentWindowUrl)
|
{
|
string js=@"<Script language='JavaScript'>
|
window.opener.parent.location.replace('"+openerParentWindowUrl+"');</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
/// º¯ÊýÃû:CloseParentWindow
|
/// ¹¦ÄÜÃèÊö:¹Ø±Õ´°¿Ú
|
/// ´¦ÀíÁ÷³Ì:
|
/// Ëã·¨ÃèÊö:
|
/// ×÷ Õß: Ëïºé±ë
|
/// ÈÕ ÆÚ: 2003-04-30 16:00
|
/// ÐÞ ¸Ä:
|
/// ÈÕ ÆÚ:
|
/// °æ ±¾:
|
/// </summary>
|
public static void CloseParentWindow()
|
{
|
string js=@"<Script language='JavaScript'>
|
window.parent.close();
|
</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
|
public static void CloseOpenerWindow()
|
{
|
string js=@"<Script language='JavaScript'>
|
window.opener.close();
|
</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
|
/// <summary>
|
/// º¯ÊýÃû:ShowModalDialogJavascript
|
/// ¹¦ÄÜÃèÊö:·µ»Ø´ò¿ªÄ£Ê½´°¿ÚµÄ½Å±¾
|
/// ´¦ÀíÁ÷³Ì:
|
/// Ëã·¨ÃèÊö:
|
/// ×÷ Õß: Ëïºé±ë
|
/// ÈÕ ÆÚ: 2003-04-30 15:00
|
/// ÐÞ ¸Ä:
|
/// ÈÕ ÆÚ:
|
/// °æ ±¾:
|
/// </summary>
|
/// <param name="webFormUrl"></param>
|
/// <returns></returns>
|
public static string ShowModalDialogJavascript(string webFormUrl)
|
{
|
string js=@"<script language=javascript>
|
var iWidth = 0 ;
|
var iHeight = 0 ;
|
iWidth=window.screen.availWidth-10;
|
iHeight=window.screen.availHeight-50;
|
var szFeatures = 'dialogWidth:'+iWidth+';dialogHeight:'+iHeight+';dialogLeft:0px;dialogTop:0px;center:yes;help=no;resizable:on;status:on;scroll=yes';
|
showModalDialog('"+webFormUrl+"','',szFeatures);</script>";
|
return js;
|
}
|
|
public static string ShowModalDialogJavascript(string webFormUrl,string features)
|
{
|
string js=@"<script language=javascript>
|
showModalDialog('"+webFormUrl+"','','"+features+"');</script>";
|
return js;
|
}
|
|
/// <summary>
|
/// º¯ÊýÃû:ShowModalDialogWindow
|
/// ¹¦ÄÜÃèÊö:´ò¿ªÄ£Ê½´°¿Ú
|
/// ´¦ÀíÁ÷³Ì:
|
/// Ëã·¨ÃèÊö:
|
/// ×÷ Õß: Ëïºé±ë
|
/// ÈÕ ÆÚ: 2003-04-30 15:00
|
/// ÐÞ ¸Ä:
|
/// ÈÕ ÆÚ:
|
/// °æ ±¾:
|
/// </summary>
|
/// <param name="webFormUrl"></param>
|
/// <returns></returns>
|
public static void ShowModalDialogWindow(string webFormUrl)
|
{
|
string js=ShowModalDialogJavascript(webFormUrl);
|
HttpContext.Current.Response.Write(js);
|
}
|
|
public static void ShowModalDialogWindow(string webFormUrl,string features)
|
{
|
string js=ShowModalDialogJavascript(webFormUrl,features);
|
HttpContext.Current.Response.Write(js);
|
}
|
public static void ShowModalDialogWindow(string webFormUrl,int width,int height,int top,int left)
|
{
|
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=no";
|
ShowModalDialogWindow(webFormUrl,features);
|
}
|
|
public static void SetHtmlElementValue(string formName,string elementName,string elementValue)
|
{
|
string js=@"<Script language='JavaScript'>if(document."+formName+"." + elementName +"!=null){document."+formName+"." + elementName +".value ="+ elementValue +";}</Script>";
|
HttpContext.Current.Response.Write(js);
|
}
|
}
|