【发布时间】:2014-11-10 22:39:26
【问题描述】:
需要从母版页调用内容页函数。 如果需要更多数据,请告诉我。
MasterPage.master.cs 看起来像
protected void Required_Function(object sender, EventArgs e)
{
// call Update_Content_Page() from content page
}
Default.aspx 看起来像
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="contentPlaceHolder" Runat="Server">
<asp:Label ID="Label1" runat="server" Text="Label">Hello people!</asp:Label>
</asp:Content>
Default.aspx.cs 看起来像
using…
public partial class _Default : System.Web.UI.Page
{
protected void Update_Content_Page()
{
Label1.Text=”Hello world”;
}
}
【问题讨论】:
-
这里是根据您的要求提供的教程:Interacting with the Content Page from the Master Page 我没有在此处粘贴确切的代码,因为解决方案相当复杂。
-
不是。我在问如何从母版页调用内容页面功能,而不是反过来。
-
我明白你为什么没有在这里放任何代码。解决方案很复杂,但代码行数很少。我稍微调整了我的代码并且它起作用了。但是,天哪,这根本不简单。我接受它作为答案,因为您链接上的信息帮助我解决了我的问题。
-
@PavelNefyodov 请发布您成功使用的代码。我也有同样的问题..
标签: c# master-pages