ASP.netµ¯³öÏûÏ¢¶Ô»°¿òµÄ·½·¨
ÎÒÃÇÔÚASP.NET³ÌÐòµÄ¿ª·¢¹ý³ÌÖУ¬³£³£ÐèÒªÏòÓû§¸ø³öÌáʾÐÅÏ¢£¬±ÈÈçÊÇ·ñ“²Ù×÷³É¹¦”£¬“È·¶¨”»¹ÊÇ“È¡Ïû”²Ù×÷¡£
(1) µã»÷Ò³ÃæÉϵİ´Å¥£¬µ¯³öÒ»¸ö¶Ô»°¿òÌáʾÊÇ“È·¶¨”»¹ÊÇ“È¡Ïû”²Ù×÷£¬ÎÒÃDzÉÓÃÔÚ°´Å¥ÖÐÌí¼ÓÊôÐÔÀ´Íê³É£º
Àý£º
public System.Web.UI.WebControls.Button btnDelRow;
btnDelRow.Attributes.Add("onclick", "return confirm('È·¶¨ÒªÉ¾Âð?');");
¡¡(2)µã»÷Ò³ÃæÉϵÄÁ´½Ó£¬µ¯³öÒ»¸ö¶Ô»°¿òÌáʾÊÇ“È·¶¨”»¹ÊÇ“È¡Ïû”²Ù×÷£¬¿ÉÔÚPage_Load()ʼþÖУ¬¸øÏ£Íû¸ø³öÈ·ÈÏÌáʾµÄ°´Å¥Ôö¼ÓÊôÐÔ£º
Àý£º
Link.Attributes.Add("onclick", "return confirm('ÄãÒªÖ´ÐÐÕâ¸ö²Ù×÷Âð£¿');");
(3) ¶ÔÓÚÒ³ÃæÍê³ÉÒ»¸ö²Ù×÷ºó£¬µ¯³öÒ»¸ö¶Ô»°¿òÌáʾÊÇ·ñ“²Ù×÷³É¹¦”¡£
Àý£º
Response.Write("<script>alert('ɾ³ý³É¹¦!')</script>");
(4)ÔÊÐí ASP.NET ·þÎñÆ÷¿Ø¼þÔÚ Page Öз¢³ö¿Í»§¶Ë½Å±¾¿é£º
public virtual void RegisterStartupScript(string key,string script);
Àý£º
if(!this.IsStartupScriptRegistered("hello"))
this.RegisterStartupScript("hello","<script>alert('ÄãºÃ!')</script>");
µ¯³ö“È·¶¨”¶Ô»°¿ò£º
Response.Write("<Script Language=JavaScript>alert('ÏûÏ¢£¡');</Script>");
µ¯³ö“È·¶¨”¶Ô»°¿ò£¬µã»÷ºóÌøתҳÃ棺
Response.Write("<Script Language=JavaScript>alert('ÏûÏ¢£¡');window.navigate('../index.aspx');</Script>");
µ¯³ö“È·¶¨”ºÍ“È¡Ïû”¶Ô»°¿ò£¬µã»÷“È·¶¨”ºóÖ´ÐÐÏà¹Ø²Ù×÷£º
·½·¨Ò»£ºÔÚPage_LoadʼþÖУ¬Ð´ÈëButton1.Attributes["onClick"]="javascript:return confirm('ÄãÈ·ÈÏҪɾ³ýÂð£¿');" £¬È»ºóÔÚButton1_OnClickʼþÖÐдÈëÄúµÄÖ´ÐдúÂë¡£
·½·¨¶þ£ºÖ±½ÓÔÚButton1_OnClikʼþÖÐдÈë
Response.Write("<Script Language=JavaScript>if(confirm('ÄãÈ·ÈÏÒªÉ
Ïà¹ØÎĵµ£º
ASP.NETµÇ½¿Ø¼þ±È½Ï¶à£¬·â×°Á˴󲿷ÖWEBÓ¦ÓÃÖÐҪʵÏÖϵͳµÇ½µÄϵÁй¦ÄÜ£¬Éæ¼°µ½ºÜ¶à·½Ãæ¡£ÖÚ¶à ASP.NET µÇ¼¿Ø¼þÒ»ÆðΪ ASP.NET Web Ó¦ÓóÌÐòÌṩ¿É¿¿µÄÎÞÐè±à³ÌµÄµÇ¼½â¾ö·½°¸¡£Ä¬ÈÏÇé¿öÏ£¬µÇ¼¿Ø¼þÓë ASP.NET ³ÉÔ±×ʸñºÍ Forms Éí·ÝÑéÖ¤¼¯³É£¬ÒÔ°ïÖúʹÍøÕ¾µÄÓû§Éí·ÝÑéÖ¤¹ý³Ì×Ô¶¯»¯¡£Ä¬ÈÏÇé¿öÏ£¬ASP.NET µÇ¼¿Ø¼þÒÔ´¿ ......
//»ñÈ¡µ±Ç°½ø³ÌµÄÍêÕû·¾¶£¬°üº¬ÎļþÃû(½ø³ÌÃû)¡£
string str = this.GetType().Assembly.Location;
result: X:\xxx\xxx\xxx.exe (.exeÎļþËùÔÚµÄĿ¼+.exeÎļþÃû)
//»ñÈ¡Ð嵀 Process ×é¼þ²¢½«ÆäÓ뵱ǰ»î¶¯µÄ½ø³Ì¹ØÁªµÄÖ÷Ä£¿éµÄÍêÕû·¾¶£¬°üº¬ÎļþÃû(½ø³ÌÃû)¡£
s ......
(Ò»).Ñ¡Ôñ»á»°×´Ì¬´æ´¢·½Ê½
ÔÚWebconfigÎļþÅäÖÃ:
<sessionState mode="???" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=y ......
/// <summary>
/// Ìṩ¾³£ÐèҪʹÓõÄһЩÑéÖ¤Âß¼¡£ ±ÈÈç ÓÊÏäÊÇ·ñºÏ·¨
/// </summary>
public class Validator
{
/// <summary>
&nbs ......
¸øÒ³ÃæµÄTextBoxÉèÖÃReadOnly="True"ʱ,ÔÚºǫ́´úÂëÖв»Äܸ³ÖµÈ¡Öµ,ϱ߼¸ÖÖ·½·¨¿ÉÒÔ±ÜÃâ:
1¡¢²»ÉèÖÃReadOnly,ÉèÖÃonfocus=this.blur()
C#´úÂë
<asp:TextBox ID="TextBox1" runat="server" onfocus=this.blur()></asp:TextBox>
<asp:TextBox ID="TextBox1" runat="serve ......