asp.net c# js·þÎñÆ÷¶Ë³£ÓÃ
using System;
using System.Web;
namespace pub.mo
{
public class js
{
private js() { }
private static string scr_j1 = "<mce:script type=\"text/javascript\"><!--
";
private static string scr_j2 = "
// --></mce:script>";
/// <summary>
/// ÊäÈëjs²¢Í£Ö¹ÔËÐÐ
/// </summary>
/// <param name="str"></param>
public static void write_js(string str)
{
HttpContext.Current.Response.Write(config.j1);
HttpContext.Current.Response.Write(scr_j1);
HttpContext.Current.Response.Write(str);
HttpContext.Current.Response.Write(scr_j2);
HttpContext.Current.Response.Write(config.j2);
HttpContext.Current.Response.End();
}
/// <summary>
/// ÊäÈëjs,ÎÞResponse.End()
/// </summary>
/// <param name="str"></param>
public static void write_js1(string str)
{
HttpContext.Current.Response.Write(config.j1);
HttpContext.Current.Response.Write(scr_j1);
HttpContext.Current.Response.Write(str);
HttpContext.Current.Response.Write(scr_j2);
HttpContext.Current.Response.Write(config.j2);
}
/// <summary>
/// µ¯³öÏûÏ¢¿ò µãÈ·¶¨ºóhistory.back();
/// </summary>
/// <param name="str"></param>
public static void alert(string str)
{
HttpContext.Current.Response.Write(config.j1);
HttpContext.Current.Response.Write(scr_j1);
HttpContext.Current.Response.Write("alert('" + str + "');history.back();");
HttpContext.Current.Response.Write(scr_j2);
HttpContext.Current.Response.Write(config.j2);
HttpContext.Current.Response.End();
}
/// <summary>
///
/// </sum
Ïà¹ØÎĵµ£º
1.¶ÔÏó³õʼ»¯£¨OnInit·½·¨£©
Ò³ÃæÖеĿؼþ(°üÀ¨Ò³Ãæ±¾Éí)¶¼ÊÇÔÚËüÃÇ×î³õµÄFORMÖб»Ê״γõʼ»¯µÄ¡£Í¨¹ýÔÚASPXÒ³ÃæµÄºǫ́´úÂëÎļþµÄ¹¹ÔìÆ÷ÖÐÉùÃ÷ÄãµÄ¶ÔÏó£¬Ò³Ã潫֪µÀ¶ÔÏóµÄÀàÐÍ£¬²¢ÖªµÀÐèÒª´´½¨¶àÉÙ¸öÕâÑùµÄ¶ÔÏó¡£Ò»µ©ÄãÔÚ¹¹ÔìÆ÷ÖÐÉùÃ÷ÁËÄãµÄ¿Ø¼þ£¬Äã¾Í¿ÉÒÔÔÚËüµÄÈκÎ×ÓÀ࣬·½·¨£¬Ê¼þ»òÕßÊôÐÔÖзà ......
1.ÈçºÎÔÚJavaScript·ÃÎÊC#º¯Êý?
·½·¨Ò»£º1¡¢Ê×ÏȽ¨Á¢Ò»¸ö°´Å¥£¬ÔÚºǫ́½«µ÷Óûò´¦ÀíµÄÄÚÈÝдÈëbutton_clickÖÐ;
2¡¢ÔÚǰ̨дһ¸öjsº¯Êý£¬ÄÚÈÝΪdocument.getElementById("btn1").click();
3¡¢ÔÚǰ̨»òºóÌ ......
½ñÌìÔÚcsdnÉÏ¿´µ½Ò»Æª²©¿Í£¬Êǽ²½â¹ØÓÚ'asp.netÖнâ¾öÒ³ÃæË¢Ðºó×ÖÌåµÈ±ä´óÎÊÌâµÄ',¿´ÁËһϣ¬¸Ð¾õдµÄ²»ÊǺÜÏêϸ¡£ÄÇô£¬ÎÒÀûÓÃËûµÄʵÀýÀ´¾ßÌåÁ˽âһϣº
ÔÎÄ£º
protected void Button1_Click(object sender, EventArgs e)
{
&nb ......
Éú³É¶Ë´¦Àí
½«ÒªÐ´ÈëµÄÖµµÄǰºóдÉÏÈç:"<![CDATA[" + string+ "]]>";
XmlNode xnformchild = doc.CreateNode(XmlNodeType.Element, dc.ColumnName.ToUpper(), "");
try
{
xnformchild.InnerXml = drform[dc.ColumnName].ToString( ......