473,783 Members | 2,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling Master Page methods directly from Content Page inline code(.aspx file)

Can it be done?

( This is a related issue to my recent post...
http://groups.google.com/group/micro...0614ae257ae699
...but with a twist. )

Here's the scenario:

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 " %>
...
<asp:Button ID="btnLogout" runat="server" Text="Logout"
OnClick="Master .Logout" />
Browse to 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.

This 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.
Apr 3 '08 #1
1 3636
On Apr 3, 5:52*pm, DevNll2...@gmai l.com wrote:
Can it be done?
Answer:
Yes it can!

The method has to be set in code, though:

btnLogout.Click += new EventHandler(Ma ster.Logout);

Apr 9 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3470
by: Lakshmi | last post by:
Hello, I have an asp page which needs to call an aspx page? How do I go about doing that? And also the codebehind for ASPX page (aspx.cs), do I have to make any changes to how that is called from aspx? Thanks. Lakshmi
5
1876
by: Silvia | last post by:
Hi I have a windows service that run a aspx page in the url http://ip/raimserver/ris/cpr002.asxp with user and password and produce an error: Time-Out sending request. RIS server can be down. Exception is :System.Net.WebException: The remote server returned an error: (401) Unauthorized. I have windows 2000 and IIS 5
1
2439
by: Kamal Ahmed | last post by:
Hi All, I have an aspx file written using vb.net that contains code both in code behind and inline. I want to access variable, object/classes declared in code behind into inline .aspx file. e.g. following code is written in File Name: Test.aspx.vb Imports System.Data Dim cCode as String cCode = "ABC"
1
1936
by: Christian Blackburn | last post by:
Hi Gang, I have trouble getting my single page Aspx pages to allow the imports and or inherits command. Can someone reply with an example. Thanks, Christian Blackburn
2
1618
by: Zach | last post by:
Re SQL Server 2005 Express When I attempt to copy the master file for backing up, it is being used by another application, even after shutting down the PC completely and powering it up again. What can I do to make back-ups? Zach
6
1625
by: Kevin Blount | last post by:
I've seen some sites that have URLs like this: blahblah.com/page.aspx?option i.e. there's no 'value' for the 'name' option. I'd like to find out how to detect if the name' is part of the URL if there's no 'value'. Can anyone tell me? I can work with "?option=value&option2=value" no problem.. but I've been
16
24146
AmirGhaffary
by: AmirGhaffary | last post by:
Hi every body i heard about some technic that we can show Page.aspx in Page.html , i think this technic used in this site (www.thescripts.com) too , i wanna know how we can do that in asp.net ?? it is so important for me !!
3
3124
by: guillermojco | last post by:
Hi, I've got an ASP.NET page that returns XLS, DOC, PDF and other files from binary fields in a database. The problem is that MS-Excel 2007 shows a security warning when trying to open the file because its name is page.ASPX instead of page.XLS (the file opens properly when this warning is accepted by the user). I thing the problem would solve if I can change the response URL from
2
1403
by: Samuel | last post by:
How can I get in the Load Event of the master file the name of the page that the user requested? Thank you, Samuel
0
2378
by: George2 | last post by:
Hello everyone, I am not sure whether I am wrong or the Windows Internals Book 4th version is wrong. Here is what the book says in Chapter 7, Memory Management from Page 444 to Page 445 --------------------
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.