2014年8月15日 星期五

ASP.NET Div加入WebUserControl並做切換


Aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/DefaultSite.Master" AutoEventWireup="true" CodeBehind="news.aspx.cs" Inherits="Debo.news" MaintainScrollPositionOnPostback="true" %>
<%@ Register TagPrefix="NewsEdit" TagName="NE" Src="~/UserTool/NewsFolder/newsedit.ascx" %>
<%@ Register TagPrefix="NewsHome" TagName="NH" Src="~/UserTool/NewsFolder/news.ascx" %>



    
Aspx.cs protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["NewsID"] != null || Request.QueryString["Action"] != null) { NewsPlace.Controls.Add(this.LoadControl("~/UserTool/NewsFolder/newsedit.ascx")); } else { NewsPlace.Controls.Add(this.LoadControl("~/UserTool/NewsFolder/news.ascx")); } }