×î½üÔÚÓÃÓû§¿Ø¼þʱ£¬ÒýÓû§¿Ø¼þµÄÒ³ÃæÓÐʱºò»áºÍÓû§¿Ø¼þ½øÐÐÊý¾ÝµÄ½»»¥£¬ÍøÉϺÃÏñºÜ¶àÈ˲»ÖªµÀºÎ»ñÈ¡
д¸öÀý×Ó˵Ã÷Ò»ÏÂ
È¡µÃÓû§¿Ø¼þÀïÃæµÄ¿Ø¼þ²¢½øÐи³Öµ
Óû§¿Ø¼þaspxÒ³´úÂë
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="HeadPanel.ascx.cs" Inherits="HeadPanel" %>
<asp:Label ID="lb1" runat="server" Text=""></asp:Label> //ÔÚÓû§¿Ø¼þÀﶨÒå µÄÁ½¸ö¿Ø¼þ
<asp:Label ID="lb2" runat="server" Text=""></asp:Label>
csÒ³´úÂë
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class HeadPanel : System.Web.UI.UserControl
{
public static string tmpSiteName = "Óû§¿Ø¼þ½øÐи³ÖµµÄ±êÌâ";
public string tmpStr="ÕâÊÇÓû§±äÁ¿";
protected void Page_Load(object sender, EventArgs e)
{
}
}
ÒýÓÃÓû§¿Ø¼þaspxÒ³´úÂë
......
ʲôÊÇMVCģʽ
MVC£¨Model-View-Controller£¬Ä£ÐÍ—ÊÓͼ—¿ØÖÆÆ÷ģʽ£©ÓÃÓÚ±íʾһÖÖÈí¼þ¼Ü¹¹Ä£Ê½¡£Ëü°ÑÈí¼þϵͳ·ÖΪÈý¸ö»ù±¾²¿·Ö£ºÄ£ÐÍ£¨Model£©£¬ÊÓͼ£¨View£©ºÍ¿ØÖÆÆ÷£¨Controller£©¡£
ÄÇôMVCģʽºÍÎÒÃÇÊìϤµÄWebFormģʽÓÐʲô²»Í¬ÄØ£¿ËûµÄ¸÷¸ö²¿·ÖÓÖÊÇÔõÑù·Ö¹¤µÄÄØ£¿
ÎÒÃÇÏÈÀ´¿´Ò»ÏÂÆÕͨµÄWebFormģʽÏ£¬ÎÒÃÇÇëÇóÒ»¸öÀýÈçhttp://www.51mvc.com/blog/index.aspxµÄURL£¬ÄÇôÎÒÃǵÄWebForm³ÌÐò»áµ½ÍøÕ¾¸ùĿ¼ÏÂȥѰÕÒblogĿ¼ÏµÄindex.aspxÎļþ£¬È»ºóÓÉindex.aspxÒ³ÃæµÄCodeBehindÎļþ(.CSÎļþ)½øÐÐÂß¼´¦Àí£¬ÆäÖлòÐíÒ²°üÀ¨µ½Êý¾Ý¿âȥȡ³öÊý¾Ý(ÆäÖеľ¹ýÔõÑùµÄBLLµ½DALÕâÀï¾Í²»Ì¸ÁË)£¬È»ºóÔÙÓÉindex.aspxÒ³ÃæÀ´³ÊÏÖ¸øÓû§¡£¼òµ¥µÄʾÒâͼÈçÏÂËùʾ£º
Ò²¾ÍÊÇÒ»¸öURLÇëÇóµÄÊÇÔÚ·þÎñÆ÷Óë¸ÃURL¶ÔӦ·¾¶ÉϵÄÎïÀíÎļþ(ASPXÎļþ»òÆäËû)£¬È»ºóÓɸÃÎļþÀ´´¦ÀíÕâ¸öÇëÇó²¢·µ»Ø½á¹û¸ø¿Í»§¶Ë¡£
µ«ÊÇ£¬¶ÔÓÚMVCģʽ£¬ÕâÊÇÔõÑùµÄÒ»¸ö¹ý³ÌÄØ£¿
ÎÒÃÇÏÈÀ´½¨Ò»¸öASP.NET MVCµÄÏîÄ¿°É¡£VS2008ĬÈÏÊÇûÓÐASP.NET MVCµÄÏîÄ¿Ä£°åµÄ£¬Ê×ÏÈÎÒÃÇÐèÒªµ½http://www.microsoft.com/downloads/details.aspx?FamilyId=A24D1E00-CD35-4F66-BAA0-2362BDDE0766&displaylang=enÈ¥Ï ......
Óû§¿ÉÒÔ´Óhttp://logging.apache.org/log4net/ÏÂÔØlog4netµÄÔ´´úÂë¡£½âѹÈí¼þ°üºó£¬ÔÚ½âѹµÄsrcĿ¼Ï½«log4net.slnÔØÈëVisual Studio .NET£¬±àÒëºó¿ÉÒԵõ½log4net.dll¡£Óû§ÒªÔÚ×Ô¼ºµÄ³ÌÐòÀï¼ÓÈëÈÕÖ¾¹¦ÄÜ£¬Ö»Ð轫log4net.dllÒýÈ빤³Ì¼´¿É.
web.config ÖеÄÅäÖãº
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
¼Óµ½ <configSections> ÀïÃæ.
<log4net debug="true">
<appender name="LogFileAppender" type="log4net.Appender.FileAppender" >
<param name="File" value="c:\Applog.txt" />
<param name="datePattern" value="yyyy-MM-dd HH:mm" />
<param name="AppendToFile" value="true" />
<layout type="log4net.Layout.PatternLayout">
  ......
±¾ÏµÁÐÎÄÕÂͨ¹ýÒ»¸öÐéÄâµÄ°¸Àý——¡¶MVC¹«¸æ·¢²¼ÏµÍ³¡·µÄ¿ª·¢¹ý³Ì£¬È«ÃæչʾÁËASP.NET MVCµÄ»ù±¾Ê¹Ó÷½·¨£¬Í¬Ê±ÔÚÌÖÂÛÁËÕâ¸ö¿ò¼ÜµÄ»ù±¾ÔÀí¡£
Õâ¸öÎÄÕÂϵÁеÄÄ¿µÄ¾ÍÊÇʹÅóÓÑÃǸüÇáËɵÄÈëÃÅASP.NET MVC¡£
Õâ¸öϵÁлá°üº¬µÄÄÚÈÝÓУºASP.NET MVC»ù±¾Ó¦Óᢻù±¾ÔÀí¡¢Â·ÓÉ´¦Àí¡¢±íµ¥´¦Àí¡¢ÓëASP.NET AJAX½áºÏ¡¢ÓëJQuery½áºÏ¡¢À¹½ØÆ÷µÈ¡£
ASP.NET MVC°¸Àý½Ì³Ì£¨»ùÓÚASP.NET MVC beta£©——µÚһƪ£º×¼±¸¹¤×÷
ÕªÒª: ±¾ÎĽ«¼òÒª½éÉÜÕâ¸öÎÄÕÂϵÁеÄÄ¿µÄ¡¢ÐÎʽ¼°´óÌåÄÚÈÝ¡£²¢ÇÒÍê³É¿ªÊ¼Ñ§Ï°Õâ¸öϵÁÐÇ°Ëù±ØÒªµÄ×¼±¸¹¤×÷¡£
ASP.NET MVC°¸Àý½Ì³Ì£¨»ùÓÚASP.NET MVC beta£©——µÚ¶þƪ£ºµÚÒ»¸öÒ³Ãæ
ÕªÒª: ±¾ÎÄÊ×ÏÈÒ»²½Ò»²½Íê³ÉDemoµÄµÚÒ»¸öÒ³Ãæ——Ê×Ò³¡£È»ºó¸ù¾ÝʵÏÖ¹ý³Ì£¬ËµÃ÷Ò»ÏÂÆäÖÐÓõ½µÄÓëASP.NET MVCÏà¹ØµÄ¸ÅÄîÓëÔÀí¡£
ASP.NET MVC°¸Àý½Ì³Ì£¨»ùÓÚASP.NET MVC beta£©——µÚÈýƪ£ºASP.NET MVCÈ«¾Ö¹Û
ÕªÒª: ±¾ÎĶÔASP.NET MVCµÄÈ«¾ÖÔËÐлúÀí ......
asp.net(c#)ÍøÒ³ÌøתÆßÖÖ·½·¨Ð¡½á
·¢²¼Ê±¼ä£º2009-11-25 11:13:03
¡¡¡¡1.Response.Redirect("http://www.yayiba.com",false);
¡¡¡¡Ä¿±êÒ³ÃæºÍÔÒ³Ãæ¿ÉÒÔÔÚ2¸ö·þÎñÆ÷ÉÏ£¬¿ÉÊäÈëÍøÖ·»òÏà¶Ô·¾¶¡£ºóÃæµÄboolֵΪÊÇ·ñÍ£Ö¹Ö´Ðе±Ç°Ò³¡£
ÌøתÏòеÄÒ³Ã棬Դ°¿Ú±»´úÌæ¡£"
ä¯ÀÀÆ÷ÖеÄURLΪз¾¶¡£
:Response.Redirect·½·¨µ¼ÖÂä¯ÀÀÆ÷Á´½Óµ½Ò»¸öÖ¸¶¨µÄURL¡£µ±Response.Redirect()·½·¨±»µ÷ÓÃʱ£¬Ëü»á´´½¨Ò»¸öÓ¦´ð£¬Ó¦´ðÍ·ÖÐÖ¸³öÁË
״̬´úÂë302£¨±íʾĿ±êÒѾ¸Ä±ä£©ÒÔ¼°ÐµÄÄ¿±êURL¡£ä¯ÀÀÆ÷´Ó·þÎñÆ÷ÊÕµ½¸ÃÓ¦´ð£¬ÀûÓÃÓ¦´ðÍ·ÖеÄÐÅÏ¢·¢³öÒ»¸ö¶ÔÐÂURLµÄÇëÇó¡£Õâ¾ÍÊÇ˵£¬
ʹÓÃResponse.Redirect·½·¨Ê±Öض¨Ïò²Ù×÷·¢ÉúÔÚ¿Í»§¶Ë£¬×ܹ²Éæ¼°µ½Á½´ÎÓë·þÎñÆ÷µÄͨÐÅ£¨Á½¸öÀ´»Ø£©£ºµÚÒ»´ÎÊǶÔÔʼҳÃæµÄÇëÇó,
µÃµ½Ò»¸ö302Ó¦´ð£¬µÚ¶þ´ÎÊÇÇëÇó302Ó¦´ðÖÐÉùÃ÷µÄÐÂÒ³Ã棬µÃµ½Öض¨ÏòÖ®ºóµÄÒ³Ãæ¡£
¡¡¡¡2.Server.Transfer("Default2.aspx?name=zhangsan",true);
Ä¿±êÒ³ÃæºÍÔÒ³Ãæ¿ÉÒÔÔÚͬһ¸ö·þÎñÆ÷ÉÏ¡£
ÌøתÏòеÄÒ³Ã棬Դ°¿Ú±»´úÌæ¡£
²¨ÇòÂÛ̳ ä¯ÀÀÆ÷ÖеÄURLΪÔ·¾¶²»±ä¡£
ĬÈÏÇé¿öÏ£¬Server.Transfer·½·¨²»»á°Ñ±íµ¥Êý¾Ý»ò²éѯ×Ö·û´®´ÓÒ»¸öÒ³Ãæ´«µÝµ½ÁíÒ»¸öÒ³Ã棬µ«Ö»Òª°Ñ¸Ã·½· ......
asp.net(c#)ÍøÒ³ÌøתÆßÖÖ·½·¨Ð¡½á
·¢²¼Ê±¼ä£º2009-11-25 11:13:03
¡¡¡¡1.Response.Redirect("http://www.yayiba.com",false);
¡¡¡¡Ä¿±êÒ³ÃæºÍÔÒ³Ãæ¿ÉÒÔÔÚ2¸ö·þÎñÆ÷ÉÏ£¬¿ÉÊäÈëÍøÖ·»òÏà¶Ô·¾¶¡£ºóÃæµÄboolֵΪÊÇ·ñÍ£Ö¹Ö´Ðе±Ç°Ò³¡£
ÌøתÏòеÄÒ³Ã棬Դ°¿Ú±»´úÌæ¡£"
ä¯ÀÀÆ÷ÖеÄURLΪз¾¶¡£
:Response.Redirect·½·¨µ¼ÖÂä¯ÀÀÆ÷Á´½Óµ½Ò»¸öÖ¸¶¨µÄURL¡£µ±Response.Redirect()·½·¨±»µ÷ÓÃʱ£¬Ëü»á´´½¨Ò»¸öÓ¦´ð£¬Ó¦´ðÍ·ÖÐÖ¸³öÁË
״̬´úÂë302£¨±íʾĿ±êÒѾ¸Ä±ä£©ÒÔ¼°ÐµÄÄ¿±êURL¡£ä¯ÀÀÆ÷´Ó·þÎñÆ÷ÊÕµ½¸ÃÓ¦´ð£¬ÀûÓÃÓ¦´ðÍ·ÖеÄÐÅÏ¢·¢³öÒ»¸ö¶ÔÐÂURLµÄÇëÇó¡£Õâ¾ÍÊÇ˵£¬
ʹÓÃResponse.Redirect·½·¨Ê±Öض¨Ïò²Ù×÷·¢ÉúÔÚ¿Í»§¶Ë£¬×ܹ²Éæ¼°µ½Á½´ÎÓë·þÎñÆ÷µÄͨÐÅ£¨Á½¸öÀ´»Ø£©£ºµÚÒ»´ÎÊǶÔÔʼҳÃæµÄÇëÇó,
µÃµ½Ò»¸ö302Ó¦´ð£¬µÚ¶þ´ÎÊÇÇëÇó302Ó¦´ðÖÐÉùÃ÷µÄÐÂÒ³Ã棬µÃµ½Öض¨ÏòÖ®ºóµÄÒ³Ãæ¡£
¡¡¡¡2.Server.Transfer("Default2.aspx?name=zhangsan",true);
Ä¿±êÒ³ÃæºÍÔÒ³Ãæ¿ÉÒÔÔÚͬһ¸ö·þÎñÆ÷ÉÏ¡£
ÌøתÏòеÄÒ³Ã棬Դ°¿Ú±»´úÌæ¡£
²¨ÇòÂÛ̳ ä¯ÀÀÆ÷ÖеÄURLΪÔ·¾¶²»±ä¡£
ĬÈÏÇé¿öÏ£¬Server.Transfer·½·¨²»»á°Ñ±íµ¥Êý¾Ý»ò²éѯ×Ö·û´®´ÓÒ»¸öÒ³Ãæ´«µÝµ½ÁíÒ»¸öÒ³Ã棬µ«Ö»Òª°Ñ¸Ã·½· ......
Ê×ÏȽ¨Á¢¿Ø¼þGridView1£¬×¢ÒâàÞ
Ò³ÃæEnableEventValidation="false"±ØÐëµÄ¡£
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="Panel1" DefaultButton="Button1" runat="server">
<asp:TextBox ID="TextBox1" Text='<%#Eval("StrValue")%>' runat="server" />
<asp:Button ID="Button1" UseSubmitBehavior="false" runat="server" Text="Button" OnClick="Button1_Click" />
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
ÎÒΪÁËʹÎÒµÄGridViewÓÐÊý¾Ý²âÊÔ£¬ËùÒÔÐÂÔöÁËtestÀ࣬¥Ö÷ÍêÈ«ÓÃÊý¾Ý¿âÀ´ÌṩÊý¾Ý¡£
public class test
{
private string strValue;
public string StrValue
{
get
{
return strValue;
......