English 中文(简体)
拆分默认值.aspx
原标题:Split up default.aspx

I have dynamic page which hides and shows a lot of stuff, div s, depending of what the user is clicking. It works great however the default.aspx gets a bit messy with all that html so I wounder if it is possible to split up the html into smaller parts and still keeping the structure of the page?

Thanks M

最佳回答

可以,将代码的子部分拆分为System.Web.UI.UserControls(.ascx)。您必须向Default.aspx注册控件的标记,然后您可以像包含<;asp:控件。

我的控制.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MyControl.ascx.cs" Inherits="MyControl" %>

<asp:Label ID="lblCoolLabel" runat="server" />

我的控制.ascx.cs:

public partial class MyControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

默认.aspx:

<!-- Registers your control -->
<%@ Register TagPrefix="controls" TagName="MyControl" Src="~/controls/MyControl.ascx" %>

<!-- Renders your control -->
<controls:MyControl ID="ucMyControl" runat="server" />
问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签