asp.net³£Óôú碼
1.µ¯³ö¶Ô»°¿ò.
a. µ¯³ö¶Ô»°¿ò£º
C# codeClientScript.RegisterStartupScript(this.GetType(), "",
"<script>window.alert('¸Ã»áԱûÓÐÌá½»ÉêÇë,ÇëÖØÐÂÌá½»£¡')</script>");
b.תÏòÖ¸¶¨Ò³Ãæ
C# code Response.Write("
<script>window.location='http://www.gongxinkang.com.cn'
</script>");//window.location.hrefÒ²¿ÉÒÔ
c. ´ò¿ªÐµÄä¯ÀÀÆ÷´°¿Ú
C# codeResponse.Write(" <script>window.open
('http://www.gongxinkang.com.cn/index.aspx') </script>");
d.È·ÈÏÊÇ·ñɾ³ý
HTML code<asp:Button ID="Button1" runat="server" Text="Button"
OnClientClick="return confirm('È·ÈÏÊÇ·ñɾ³ý£¿')" />
»òÕß
C# code Button1.Attributes.Add("OnClick", "return window.confirm('È·ÈÏ
ÊÇ·ñɾ³ý£¿')")
OnClientClick ÊôÐÔÀ´Ö¸¶¨ÔÚÒý·¢Ä³¸ö Button ¿Ø¼þµÄ Click ʼþʱËù
Ö´Ðеĸ½¼Ó¿Í»§¶Ë½Å±¾¡£return window.confirm('È·ÈÏÊÇ·ñɾ³ý£¿')·µ»ØÖµÈç¹û
Ϊfalse£¬¾Í²»»áÖ´ÐÐÌá½»±íµ¥µ½·þÎñÆ÷µÄ½Å±¾ÃüÁî¡£
Response.Write ÖеÄjavascript ×ÜÊÇ·¢ÉúÔÚ
ClientScript.RegisterStartupScriptÖеÄjavascript ֮ǰ£¬ÎÒÊÇÕâôÀí½â£º
1. ClientScript.RegisterStartupScript ÓÃÓÚÌí¼ÓÔÚÒ³Ãæ </form>֮ǰ
Ìí¼Ójavascript½Å±¾£¬¿ÉÒÔÈ·¶¨·þÎñÆ÷¶Ë <form>±êÇ©µÄËùÓÐhtmlÔªËØ ¶¼ÒѾ´´
½¨³öÀ´¡£
2.Response.Write½«ÐÅϢдÈë HTTP ÏìÓ¦Êä³öÁ÷£¬Äã»á·¢ÏÖÆ½Ê±
Response.WriteµÄÄÚÈÝ×ÜÊÇÔÚÒ³Ãæ¶¥¶Ë,htmlÔªËØ ¶¼»¹Ã»ÓÐÒѾ´´½¨³öÀ´¡£
2. ɾ³ýÎļþ
C# codestring filename ="aa.txt";
System.IO.File.Delete(Server.MapPath("~/aa.txt"));
3.°ó¶¨ÏÂÀÁбí¿ò
C# code Dictionary<string, int> dic = new Dictionary<string, int>();
dic.Add("ÇëÑ¡Ôñ", -1);
dic.Add("aa",0);
dic.Add("eew",2);
Ïà¹ØÎĵµ£º
ÎÄÕ³ö´¦£ºhttp://hi.baidu.com/richiezheng/blog/item/8bb94b8692315b3867096efa.html
ÀûÓÃASP.NET¼¼Êõ¶¯Ì¬Éú³ÉHTMLÒ³Ãæ
˼·
¡¡¡¡1. ÀûÓÃÈçDw-MxÕâÑùµÄ¹¤¾ßÉú³Éhtml¸ñʽµÄÄ£°å£¬ÔÚÐèÒªÌí¼Ó¸ñʽµÄµØ·½¼ÓÈëÌØÊâ±ê¼Ç(Èç$htmlformat$),¶¯Ì¬Éú³ÉÎļþʱÀûÓôúÂë¶ÁÈ¡´ËÄ£°å£¬È»ºó»ñµÃǰ̨ÊäÈëµÄÄÚÈÝ£¬Ìí¼Óµ½´ËÄ£°åµÄ±ê¼ÇλÖÃÖ ......
ÏȽ¨¸öhtmlÄ£°æÒ³(template.htm)£º
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>$title</title>
& ......
¸ø³öÒ»¸ö×Ö·û´®£¬Èç¡°ÖйúChinaÎÒ°®ÄãI love you¡±£¬³ÌÐò¿ÉÒÔʵÏÖÖÐÓ¢ÎĵÄÇø±ð;
ʶ±ð½á¹ûÈçÏ£º¹²ËĸöÔªËØ
Öйú
China
ÎÒ°®Äã
I love you
string ptn = "[\u4e00-\u9fa5]+|[a-zA-Z\\s]+";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(ptn);
s ......
ǰ̨:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
......
Ò». ʹÓÃQueryString±äÁ¿
¡¡¡¡¡¡¡¡QueryStringÊÇÒ»Öַdz£¼òµ¥Ò²ÊÇʹÓñȽ϶àµÄÒ»ÖÖ´«Öµ·½Ê½£¬µ«ÊÇËü½«´«µÝµÄÖµÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸ÖÐ,Èç¹ûÊÇ´«µÝÒ»¸ö»ò¶à¸ö°²È«ÐÔÒªÇ󲻸߻òÊǽṹ¼òµ¥µÄÊýֵʱ£¬¿ÉÒÔʹÓÃÕâ¸ö·½·¨¡£
Response.Redirect( "target.aspx?param1=hello& ......