Calling a function from the master page
masterpage.master
code
protected void btnAddLink_Click(object sender, EventArgs e)
{
//how can call btnSendMessage_Click
}
page1.aspx
<%@ Page Language="C#" MasterPageFile="~/masterpage.master" AutoEventWireup开发者_C百科="true"
CodeFile="page1.aspx.cs" Inherits="page1"%>
Code
protected void btnSendMessage_Click(object sender, EventArgs e)
{
//how call btnAddLink_Click
}
how can call btnAddLink_Click
in page1.aspx
how can call btnSendMessage_Click
in masterpage.master
In the top of he ASPX, just below the @Page tag, add a <%@MasterType... tag.
<%@ Page Language="C#" MasterPageFile="~/masterpage.master" AutoEventWireup="true" CodeFile="page1.aspx.cs" Inherits="page1"%>
<%@ MasterType VirtualPath="~/masterpage.master" %>
Then, in the code behind:
protected void btnSendMessage_Click(object sender, EventArgs e)
{ Master.btnAddLink_Click(Nothing,Nothing); }
精彩评论