ASP.NET MVC2 ѧϰ±Ê¼ÇÖ®URL·ÓÉ
н¨Ò»¸öĬÈϵÄASP.NET MVC2Ó¦ÓóÌÐò£¬ÏµÍ³»áĬÈϵÄÉú³É°üº¬»ù±¾¹¦ÄܵÄÓ¦ÓóÌÐò£¬²é¿´ÕâЩÉú³ÉµÄ´úÂ룬¿É°ïÖúÎÒÃÇÀí½âASP.NET MVC2¡£ÏÂÃæÊǶÔURL·ÓɵÄÀí½â£¬ÒÔ±¸Íü¡£
Ò»¡¢Global.asax.csÖеĴúÂ룺
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "About", id = "" } // Parameter defaults
);
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
}
Application_StartÊÇÍøÕ¾Æô¶¯ºó×îÏÈÖ´ÐеÄʼþ£¬ËùÒÔ¶ÔÍøÂç·ÓɵÄÉèÖ÷ÅÔÚ´Ë´¦£¬¾ßÌåͨ¹ý·½·¨routes.MapRoute("Default",¡¡"{controller}/{action}/{id}",¡¡ new {controller = "Home", action = "Index", id = ""}¡¡);ʵÏÖ£¬·½·¨µÄµÚÒ»¸ö²ÎÊýÊÇ·ÓɵÄÃû×Ö£
Ïà¹ØÎĵµ£º
ÔÚûÓÐ<asp:UpdatePanel ID="up" runat="server"> <ContentTemplate>ÎÞˢл·¾³ÖУº
Response.Write("<script>alert('¹§Ï²Äú£¬Òѳɹ¦¼ÓÈëµ½ÄúµÄÈ˲ſ⣡');</script>");
ÔÚÓÐ<asp:UpdatePanel ID="up" runat="server"> <ContentTemplate>ÎÞˢл·¾³Ö ......
¸Õ¸Õ ¿´µ½Õâôһ¸öÎÊÌ⣬ÕâÀïÒ²×ö¸ö±ê¼Ç£ºhttp://topic.csdn.net/u/20080411/14/7b0f9da5-0413-4149-91e9-72c3df3018a3.html?seed=327251592
µÚÒ»ÖÖ·½Ê½£º
//ÔÚVisual Studio 2008Öе÷ÊÔͨ¹ý
testPop_Page.aspx:Ö÷Ò³ÃæASPX´úÂë
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  ......
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 ......
1. Êʵ±Ê¹ÓÃUpdatePanel
2. ÀûÓÃWebService·½·¨¶¯Ì¬Éú³ÉÓû§¿Ø¼þµÄÄÚÈÝ£¬±ÜÃâUpdatePanel»Ø´«Ôì³ÉµÄÐÔÄÜËðʧ£¨ViewState£©
3. ToolkitScriptManager´úÌæScriptManager
4. <asp:ScriptManager runat="server" ID="sm" ScriptMode="Release" EnablePartialRendering="false"
......