The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller. The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating MVC-based Web applications. The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System.Web.Mvc namespace and is a fundamental, supported part of the System.Web namespace. MVC is a standard design pattern that many developers are familiar with. Some types of Web applications will benefit from the MVC framework. Others will continue to use the traditional ASP.NET application pattern that is based on Web Forms and postbacks. Other types of Web applications will combine the two approaches; neither approach excludes the other. MVC¼Ü¹¹Ä£ ......
1. ´ò¿ªÐµĴ°¿Ú²¢´«ËͲÎÊý£º
´«ËͲÎÊý£º
response.write("£¼script£¾window.open('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"')£¼/script£¾")
½ÓÊÕ²ÎÊý£º
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.Ϊ°´Å¥Ìí¼Ó¶Ô»°¿ò
Button1.Attributes.Add("onclick","return confirm('È·ÈÏ?')");
button.attributes.add("onclick","if(confirm('are you sure...?')){return true;}else{return false;}")
3.ɾ³ý±í¸ñÑ¡¶¨¼Ç¼
int intEmpID = (int)MyDataGrid.DataKeys[e.Item.ItemIndex];
string deleteCmd = "Delete from Employee where emp_id = " + intEmpID.ToString()
4.ɾ³ý±í¸ñ¼Ç¼¾¯¸æ
private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e)
{
¡¡switch(e.Item.ItemType)
¡¡{
case ListItemType.Item :
case ListItemType.AlternatingItem :
case ListItemType.EditItem:
¡¡TableCell myTableCell;
¡¡myTableCell = e.Item.Cells[14];
¡¡LinkButton myDeleteButton ;
¡¡myDeleteButton = (LinkButton)myTableCell.Controls[0];
¡¡myDe ......
ASP.NET³ÌÐòÖг£ÓôúÂë»ã×Ü
1.×Ô¶¨ÒåÒì³£´¦Àí
//×Ô¶¨ÒåÒì³£´¦ÀíÀà
using System;
using System.Diagnostics;
namespace MyAppException
{
¡¡/// £¼summary£¾
¡¡/// ´ÓϵͳÒì³£ÀàApplicationException¼Ì³ÐµÄÓ¦ÓóÌÐòÒì³£´¦ÀíÀà¡£
¡¡/// ×Ô¶¯½«Òì³£ÄÚÈݼǼµ½Windows NT/2000µÄÓ¦ÓóÌÐòÈÕÖ¾
¡¡/// £¼/summary£¾
¡¡public class AppException:System.ApplicationException
¡¡{
¡¡¡¡public AppException()
¡¡¡¡{
¡¡¡¡¡¡if (ApplicationConfiguration.EventLogEnabled)LogEvent("³öÏÖÒ»¸öδ֪´íÎó¡£");
¡¡¡¡}
¡¡public AppException(string message)
¡¡{
¡¡¡¡LogEvent(message);
¡¡}
¡¡public AppException(string message,Exception innerException)
¡¡{
¡¡¡¡LogEvent(message);
¡¡¡¡if (innerException != null)
¡¡¡¡{
¡¡¡¡¡¡LogEvent(innerException.Message);
¡¡¡¡}
¡¡}
¡¡//ÈÕÖ¾¼Ç¼Àà
¡¡using System;
¡¡using System.Configuration;
¡¡using System.Diagnostics;
¡¡using System.IO;
¡¡using System.Text;
¡¡using System.Threading;
¡¡namespace MyEventLog
¡¡{
¡¡¡¡/// £¼summary£¾
¡¡¡¡/// ʼþÈÕÖ¾¼Ç¼À࣬ÌṩʼþÈÕÖ¾¼ÇÂ¼Ö ......
ASP.NET·ÀÖ¹SQL×¢È뺯Êý:
using System;
using System.Text.RegularExpressions;
using System.Web;
namespace FSqlKeyWord
......{
/**//**//**//// <summary>
/// SqlKey µÄժҪ˵Ã÷¡£
/// </summary>
public class SqlKey
......{
private HttpRequest request;
private const string StrKeyWord = @"select|insert|delete|from|count(|drop table|update|truncate|asc(|mid(|char(|xp_cmdshell|exec master|netlocalgroup administrators|:|net user|""|or|and";
private const string StrRegex = @"[-|;|,|/|(|)|[|]|}|{|%|@|*|!|']";
public SqlKey(System.Web.HttpRequest _request)
......{
//
&nbs ......
ASP.NET·ÀÖ¹SQL×¢È뺯Êý:
using System;
using System.Text.RegularExpressions;
using System.Web;
namespace FSqlKeyWord
......{
/**//**//**//// <summary>
/// SqlKey µÄժҪ˵Ã÷¡£
/// </summary>
public class SqlKey
......{
private HttpRequest request;
private const string StrKeyWord = @"select|insert|delete|from|count(|drop table|update|truncate|asc(|mid(|char(|xp_cmdshell|exec master|netlocalgroup administrators|:|net user|""|or|and";
private const string StrRegex = @"[-|;|,|/|(|)|[|]|}|{|%|@|*|!|']";
public SqlKey(System.Web.HttpRequest _request)
......{
//
&nbs ......
ÓÐÈËÒ²ÎÊÁ˸öÔÚÏßͳ¼ÆµÄÎÊÌ⣬ÎҵļûÒâÊÇÕâÑùµÄ£º
ÔÚApplication_StartʼþÖмÓÈëÒÔÏ´úÂ룺
Application.Lock();
Application.["UserCount"]=0;
Application.Unlock();
Session_StartʼþÖмÓÈëÒÔÏ´úÂ룺
Application.Lock();
Application["UserCount']=Int32.Parse(Application["UserCount"].Tostring())+1;
Application.UnLock();
Session_EndʼþÖмÓÈëÒÔÏ´úÂ룺
Application.Lock();
Application["UserCount"]=Int32.Parse(Application["UserCount"].Tostring())-1;
Application.UnLock();
ÔÚÒªÏÔʾµÄµØ·½Ð´¸öº¯Êý¼ÓÈëÒÔÏ´úÂ룺
Response.Write(Application["UserCount"].Tostring());
Õâ¾ÍOKÁË ......
×î½üд³ÌÐòÒ»Ö±³öÎÊÌ⣬ÒÔǰһ¸öÕ¾Èý¼¸Ìì¾ÍÇáËɸ㶨£¬ÏÖÔÚÒ»¸öÄ£¿é¾³£¸ã°ëÌ죬NND
ÏÂÎ翪·¢¿áÒ×»¯×±Æ·É̳Ç(http://www.koyee.net)Ò»¸ö±íµ¥Ìá½»¹¦ÄÜÄ£¿é£¬±¾µØÈκÎÎÊÌⶼûÓÐÁË£¬´«µ½·þÎñÆ÷Éϱ¾ÒÔΪûÊÂÁË£¬ºóÀ´Ò»¼ì²éËùÓеÄÑéÖ¤¿Ø¼þ¶¼²»Æð×÷ÓÃÁË£¬Ö±½Ó¶¼Ìá½»¹ýÈ¥ÁË£¬ÓôÃÆ£¬ÔÒÔΪ³ÌÐò±»¸Ä´íÁË£¬¼ì²é±¾µØ»¹ÊÇûÈκÎÎÊÌ⣬¼ÌÐøÓÖ´«ÁËÒ»±é£¬ÔÚ·þÎñÆ÷ÉÏ¿´»¹ÊDz»ÐУ»
Ò»ÏÂÎçɶҲû¸É£¬°Ù¶È¡¢¹È¸èµÄ²é£¬¼¼ÊõȺµÄÎÊ£¬ÅóÓѵÄÁÄ£¬×îÖÕ×ÜËãÊǽâ¾öÁË£¬°¥£¬Ò²ÈÃ×Ô¼ºÃ÷°×ÁËÒ»¸öµÀÀí£¬¾ÛɳÄܳÉËþ Ë®µÎÄÜʯ´© ÌúèÆ±ä³ÉÕë Öñ×Ó³ÉÑÀÇ©£»ºÜ¶àÊÂÇé²»ÊÇÎÒÃDz»Äܽâ¾ö£¬¶øÊÇÒòΪÎÒÃÇûÓнâ¾ö֮ǰ°ë;¶ø·Ï£¬Ö»ÒªÅ¬Á¦£¬Ò»ÇнÔÓпÉÄÜ¡£O(∩_∩)O~
˵×Å˵×ÅÓÖÅÜÌâÁË£¬ÑÔ¹éÕý´«£¬¹«²¼½â¾ö·½·¨£º£¨asp.netÑéÖ¤¿Ø¼þ²»Æð×÷ÓõĽâ¾ö°ì·¨£©
ÕâÖ÷ÒªÊÇ·þÎñÆ÷ûÓа²×°ÏàÓ¦µÄ ¿Í»§¶Ë ½Å±¾µÄÔÒò£¬ÔÚ·þÎñÆ÷ÉÏÔËÐÐ aspnet_regiis -c(»òÕßaspnet_iisreg -c ²»Í¬°æ±¾¿ÉÄܲ»Í¬ ) ÃüÁî¾Í¿ÉÒÔÁË£¬¡¾×¢£ºÒ»¶¨ÒªÔÚÃüÁîÌáʾϽøÈëC:\WINDOWS\Microsoft.NET\Framework\v2.0.50727ÀàËÆµÄĿ¼ÏÂÖ´ÐС¿
¡£´ó¼Ò¿´Ò»ÏÂhttp://www.koyee.netÕâ¸öÕ¾µÄ¶©µ¥Ìá½»Äǿ飬¾ÍÊÇÎÒ×öµÄ£¬ÏÖÔÚÒѾûÎÊÌâÁË¡£
·þÎñÆ÷ÉÏÃüÁîÖ´ ......