Re: Use Master Page functions in a Content Page?

Re: Use Master Page functions in a Content Page?

am 02.04.2008 02:25:54 von DevNll2002

Here's a followup issue on the same subject:

Method in MyMaster.master.cs:
public void Logout(object sender, EventArgs e)
{
Response.Write("You are logged out!");
}


Code in MyContent.aspx:
<%@ MasterType VirtualPath="~/MyMaster.master" %>
...
OnClick="Master.Logout" />


Access the page, and in big red letters:
Server Application Unavailable


Application log in Event Viewer shows:
Event Type: Error
Event Source: ASP.NET 2.0.50727.0
Event Category: None
Event ID: 1000
Description: aspnet_wp.exe (PID: 3368) stopped unexpectedly.

Happens every time that 'Master.' is used directly in the .aspx code.

A workaround is to call Master.Logout from within a MyContent.aspx.cs
method, then reference the latter method in MyContent.aspx.

MyContent.aspx *is* seeing the method in MyMaster.master.cs, because
it will throw errors for certain things like leaving out the overloads
in the Logout method declaration.

Is there a correct syntax for calling a Master Page method directly
from inline code, or should it just not be done?

Thanks.