ASP.NETµ¯³ö¶Ô»°¿ò¼¸ÖÖ»ù±¾·½·¨
ASP.NETµ¯³ö¶Ô»°¿ò¼¸ÖÖ»ù±¾·½·¨
ASP.NETµ¯³ö¶Ô»°¿ò¼¸ÖÖ»ù±¾·½·¨
ÎÒÃÇÔÚ.NET³ÌÐòµÄ¿ª·¢¹ý³ÌÖУ¬³£³£ÐèÒªºÍÓû§½øÐÐÐÅÏ¢½»»¥£¬±ÈÈçÖ´ÐÐijÏî²Ù×÷ÊÇ·ñ³É¹¦£¬“È·¶¨”»¹ÊÇ“È¡Ïû”£¬ÒÔ¼°Ñ¡Ôñ“È·¶¨”»ò“È¡Ïû”ºóÊÇ·ñÐèÒªÌøתµ½Ä³¸öÒ³ÃæµÈ£¬ÏÂÃæÊDZ¾È˶Գ£ÓöԻ°¿òʹÓõÄС½á£¬Ï£Íû¶Ô´ó¼ÒÓÐËù°ïÖú£¬Í¬Ê±Ò²»¶Ó´ó¼Ò²¹³ä¡£
(1) µã»÷Ò³ÃæÉϵİ´Å¥£¬µ¯³öÒ»¸ö¶Ô»°¿òÌáʾÊÇ“È·¶¨”»¹ÊÇ“È¡Ïû”²Ù×÷£¬ÎÒÃDzÉÓÃÔÚ°´Å¥ÖÐÌí¼ÓÊôÐÔÀ´Íê³É£º
¾ÙÀýÈçÏ£º
public System.Web.UI.WebControls.Button btnDelRow;
btnDelRow.Attributes.Add("onclick", "return confirm('È·¶¨ÒªÉ¾Âð?');");
(2) µã»÷Ò³ÃæÉϵİ´Å¥£¬µ¯³öÒ»¸ö¶Ô»°¿òÌáʾÊÇ“È·¶¨”»¹ÊÇ“È¡Ïû”²Ù×÷£¬Ñ¡Ôñ“È·¶¨”»ò“È¡Ïû”ºóÌøתµ½ÏàÓ¦µÄÒ³Ã棺
¾ÙÀýÈçÏ£º
string strMsg, string strUrl_Yes, string strUrl_No;
Response.Write("<Script Language='JavaScript'>if ( window.confirm('"+strMsg+"')) { window.location.href='" + strUrl_Yes +
"' } else {window.location.href='"+ strUrl_No +"' };</script>");
(3) ¶ÔÓÚÒ³ÃæÍê³ÉÒ»¸ö²Ù×÷ºó£¬µ¯³öÒ»¸ö¶Ô»°¿òÌáʾÊÇ·ñ“²Ù×÷³É¹¦”¡£
¾ÙÀýÈçÏ£º
Response.Write("<script>alert('ɾ³ý³É¹¦!')</script>");
(4) ¶ÔÓÚÒ³ÃæÍê³ÉÒ»¸ö²Ù×÷ºó£¬µ¯³öÒ»¸ö¶Ô»°¿òÌáʾÊÇ·ñ“²Ù×÷³É¹¦”ºóÌøתµ½Ä³Ò»¸öÒ³Ãæ¡£
¾ÙÀýÈçÏ£º
Response.Write("<script>alert('ɾ³ý³É¹¦!');window.location.href ='www.cnblogs.com'</script>");
(5)ÔÊÐí ASP.NET ·þÎñÆ÷¿Ø¼þÔÚ Page Öз¢³ö¿Í»§¶Ë½Å±¾¿é£º
public virtual void RegisterStartupScript(string key,string script);
¾ÙÀýÈçÏ£º
if(!this.IsStartupScriptRegistered("hello"))
this.RegisterStartupScript("hello","<script>alert('ÄãºÃ!')</script>");
(6)ÏÂÃæÊDZ¾ÈËÕûÀíµÄÒ»¸öµ¯³ö¶Ô»°¿òµ÷ÓÃÀࣺ
using System;
using System.Web;
namespace ShowMessage
{
/// <summary>
/// Msg µÄժҪ˵Ã÷¡£
/// </summary>
public class ShowMessage
{
public ShowMessage()
{
//
// TODO: ÔÚ´Ë´¦Ìí¼Ó¹¹Ô캯ÊýÂß¼
//
}
public static void ShowMessage(string strMsg)
{
Ïà¹ØÎĵµ£º
Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯
¡¡¡¡Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
¡¡¡¡·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ÐèҪʱȡ³ö£¬¹Ø±ÕÊ ......
¾³£¼ûµ½ÓÐÈË˵ÔÚASP.netÖв»ÒªÊ¹Óö¯Ì¬¿Ø¼þ,ÎÒÏëÖ÷ÒªµÄÔÒòÔÚÓÚʹÓö¯Ì¬¿Ø¼þ»á´øÀ´Ò»Ð©ÎÊÌâ,ÔÚ×öÏîÄ¿µÄ¹ý³ÌÖÐ,ÎÒ½«Óɶ¯Ì¬¼ÓÔؿؼþÒý·¢µÄ×ÜÊÇ×÷ÁËÒ»¸öССµÄ×ܽá.
1 ¡¢ÔÚʹÓÃLoadControl¼ÓÔؿؼþºó,Óû§¿Ø¼þÖеÄijЩ¿Ø¼þ²»ÔÙÏìӦʼþ¡£
Õâ¸öÎÊÌâÖ÷ÒªÊÇÓÉÓÚ½«¿Ø¼þ¼ÓÔØ·ÅÔÚif (!Page ......
Èç¹ûÄãÒѾÓн϶àµÄÃæÏò¶ÔÏ󿪷¢¾Ñ飬Ìø¹ýÒÔÏÂÕâÁ½²½£º
µÚÒ»²½¡¡ÕÆÎÕÒ»ÃÅ.NETÃæÏò¶ÔÏóÓïÑÔ£¬C#»òVB.NET ÎÒÇ¿ÁÒ·´¶ÔÔÚûϵͳѧ¹ýÒ»ÃÅÃæÏò¶ÔÏó(OO)ÓïÑÔµÄÇ°ÌáÏÂȥѧASP.NET¡£ ASP.NETÊÇÒ»¸öÈ«ÃæÏò¶ÔÏóµÄ¼¼Êõ£¬²»¶®OO£¬ÄǾø¶Ôѧ²»ÏÂÈ¥!
¡¡¡¡µÚ¶þ²½¡¡¶Ô.NET FrameworkÀà¿âÓÐÒ»¶¨µÄÁ˽⠿ÉÒ ......
ҪʵÏÖa¿Ø¼þ¿Ø¼þ´¥·¢b¿Ø¼þ·þÎñÆ÷¶Ëʼþ£¬Ðè¸øa¿Ø¼þÌí¼Ójs½Å±¾£¬ÒÔb¿Ø¼þÃûÒåÌá½»Ò³Ã棬¾ßÌå´úÂ룺
var theForm = document.forms['form1'];
theForm.__EVENTTARGET.value = "b"; //´¥·¢b¿Ø¼þ·þÎñÆ÷¶Ë·½·¨
theForm.__EVENTARGUMENT.value = "a trigger";//´«µÝµÄ²ÎÊý
theForm.submit();
×¢Ò⣺ÐèÒªÉèÖÃÒ³ÃæÊôÐÔÖÐµÄ enab ......