|
|
|
start date: Wed, 8 Aug 2007 16:34:30 -0500,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Rick am
|
|
2
Sergey Poberezovskiy
|
|
3
(Jialiang Ge [MSFT])
|
|
4
Rick am
|
|
5
(Jialiang Ge [MSFT])
|
|
6
Rick am
|
|
7
(Jialiang Ge [MSFT])
|
|
8
Rick am
|
|
9
(Jialiang Ge [MSFT])
|
|
10
(Jialiang Ge [MSFT])
|
Accessing Properties in masterpage from content file
I am trying to access the properties defined int a masterpage from within a content page. the properties are not showing up when I try to access them from the content page.
Anyone have any suggestions?
MasterPage:
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="BasePageMaster.master.vb" Inherits="Digecenter.BasePageMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
MasterPage Code:
Public Partial Class BasePageMaster
Public Property PageTitle() As String
Get
Return _pageTitle
End Get
Set(ByVal Value As String)
_pageTitle = Value
End Set
End Property
End Class
Content page Html:
<%@ Register TagPrefix="iswebgrid" Namespace="ISNet.WebUI.WebGrid" Assembly="ISNet.WebUI.WebGrid" %>
<%@ Page CodeBehind="codebehind.aspx.vb" inherits="codebehindfilenamehere" Language="vb" AutoEventWireup="false" enableViewStateMac="false" MasterPageFile="~/DigecenterBasePage.Master" %>
<%@ MasterType VirtualPath="~/MasterPages/BasePageMaster.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat=server>
--content here
</Content>
Content Page Code Behind:
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
NOT SEEING THE PROPERTIES IN THE intelesense
Dim s as string = Me.Masterpage.property
End Sub
Thanks in Advance!
Date:Wed, 8 Aug 2007 16:34:30 -0500
Author:
|
RE: Accessing Properties in masterpage from content file
Rick,
If you look closely, it seems that you have a discrepency in your locations:
Content page Html:
<%@ Page ... MasterPageFile="~/DigecenterBasePage.Master" %>
<%@ MasterType VirtualPath="~/MasterPages/BasePageMaster.Master" %>
could that be what's confusing VS?
"Rick" wrote:
>
> I am trying to access the properties defined int a masterpage from within a content page. the properties are not showing up when I try to access them from the content page.
>
> Anyone have any suggestions?
>
> MasterPage:
> <%@ Master Language="VB" AutoEventWireup="false" CodeBehind="BasePageMaster.master.vb" Inherits="Digecenter.BasePageMaster" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
> </asp:ContentPlaceHolder>
> </div>
> </form>
> </body>
> </html>
>
> MasterPage Code:
> Public Partial Class BasePageMaster
>
> Public Property PageTitle() As String
>
> Get
>
> Return _pageTitle
>
> End Get
>
> Set(ByVal Value As String)
>
> _pageTitle = Value
>
> End Set
>
> End Property
>
> End Class
>
>
> Content page Html:
> <%@ Register TagPrefix="iswebgrid" Namespace="ISNet.WebUI.WebGrid" Assembly="ISNet.WebUI.WebGrid" %>
> <%@ Page CodeBehind="codebehind.aspx.vb" inherits="codebehindfilenamehere" Language="vb" AutoEventWireup="false" enableViewStateMac="false" MasterPageFile="~/DigecenterBasePage.Master" %>
> <%@ MasterType VirtualPath="~/MasterPages/BasePageMaster.Master" %>
>
> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat=server>
> --content here
> </Content>
>
> Content Page Code Behind:
> Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
>
> NOT SEEING THE PROPERTIES IN THE intelesense
>
> Dim s as string = Me.Masterpage.property
>
> End Sub
>
> Thanks in Advance!
>
>
>
>
>
>
>
>
>
Date:Wed, 8 Aug 2007 19:16:01 -0700
Author:
|
RE: Accessing Properties in masterpage from content file
Hello Rick,
I have tested you sample code on my side. The content page is able to
access the property of the master page after some small modifications of
your codes.
1. Attribute 'CodeBehind' in the @Page directive is no longer supported in
ASP.NET 2.0, so I changed the 'CodeBehind' to 'CodeFile' in both
BasePagemaster.master and codebehind.aspx.
2. In your Content page, you set the MasterPageFile in @Page directive as
'~/DigecenterBasePage.Master'. In the meantime, you set the VirtualPath of
@MasterType directive as '~/MasterPages/BasePageMaster.Master'. What is the
relationship between these two master pages? If they are simply inheriting
from System.Web.UI.MasterPage, you will get an exception: 'Unable to cast
object of type 'ASP.digecenterbasepage_master' to type
'ASP.masterpages_basepagemaster_master' in runtime. In my test, I change
the former to '~/MasterPages/BasePageMaster.Master'
3. In your content page html, you references a 3rd party control:
ISNet.WebUI.WebGrid. For convenience, I removed the line on my side.
After I made the changes above, I build the project and finally see that
the master property 'PageTitle' shows in the intelligence. Please have a
try and let me know whether it works on your side.
Sincerely,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Thu, 09 Aug 2007 02:44:39 GMT
Author:
|
Re: Accessing Properties in masterpage from content file
I've made the following changes: When I change CodeBehind to Codefile I get
the following error:
'Context' is not a member of 'PageName.aspx'
<%@ Page Codefile="~/customer_clientswebgrid_edit.aspx.vb"
inherits="Digecenter.Customer_ClientsWebGrid_Edit" Language="vb"
AutoEventWireup="false" enableViewStateMac="false"
MasterPageFile="~/MasterPages/BasePageMaster.Master" %>
<%@ MasterType TypeName="DigeMaster"
VirtualPath="~/MasterPages/BasePageMaster.Master" %>
"Jialiang Ge [MSFT]" wrote in message
news:boRrB9i2HHA.5868@TK2MSFTNGHUB02.phx.gbl...
> Hello Rick,
>
> I have tested you sample code on my side. The content page is able to
> access the property of the master page after some small modifications of
> your codes.
> 1. Attribute 'CodeBehind' in the @Page directive is no longer supported in
> ASP.NET 2.0, so I changed the 'CodeBehind' to 'CodeFile' in both
> BasePagemaster.master and codebehind.aspx.
> 2. In your Content page, you set the MasterPageFile in @Page directive as
> '~/DigecenterBasePage.Master'. In the meantime, you set the VirtualPath of
> @MasterType directive as '~/MasterPages/BasePageMaster.Master'. What is
> the
> relationship between these two master pages? If they are simply inheriting
> from System.Web.UI.MasterPage, you will get an exception: 'Unable to cast
> object of type 'ASP.digecenterbasepage_master' to type
> 'ASP.masterpages_basepagemaster_master' in runtime. In my test, I change
> the former to '~/MasterPages/BasePageMaster.Master'
> 3. In your content page html, you references a 3rd party control:
> ISNet.WebUI.WebGrid. For convenience, I removed the line on my side.
>
> After I made the changes above, I build the project and finally see that
> the master property 'PageTitle' shows in the intelligence. Please have a
> try and let me know whether it works on your side.
>
> Sincerely,
> Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> For MSDN subscribers whose posts are left unanswered, please check this
> document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications. If you are using Outlook Express/Windows Mail, please make sure
> you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
> see your reply promptly.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
Date:Thu, 9 Aug 2007 10:25:48 -0500
Author:
|
Re: Accessing Properties in masterpage from content file
Hello Rick
"Context" is a member of "System.Web.UI.Page". If you do not specify the
attributes 'CodeFile' and 'Inherits' in the @Page directive correctly, you
will receive the error: "Context is not a member of PageName.aspx". Please
check your CodeFile path and the 'Inherits' attribute, and let me know if
this suggestion could help you resolve the issue.
Besides, the MasterType directive must have exactly one attribute: TypeName
or VirtualPath. Please remove one from your MasterType directive.
Here is my test code for your references:
The structure of the test site:
Default.aspx
Default.aspx.vb
MasterPages\BasePageMaster.master
MasterPages\BasePageMaster.master.vb
In Default.aspx:
<%@ Page Language="VB" MasterPageFile="~/MasterPages/BasePageMaster.master"
EnableViewStateMac="false" AutoEventWireup="false"
CodeFile="~/Default.aspx.vb" Inherits="Digecenter._Default" title="Untitled
Page" %>
<%@ MasterType VirtualPath="~/MasterPages/BasePageMaster.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
</asp:Content>
In Default.aspx.vb:
Namespace Digecenter
Partial Class _Default
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Master.PageTitle = "hello world"
End Sub
End Class
End Namespace
In BasePageMaster.master:
<%@ Master Language="VB" AutoEventWireup="false"
CodeFile="BasePageMaster.master.vb" Inherits="Digecenter.BasePageMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
In BasePageMaster.master.vb
Namespace Digecenter
Partial Public Class BasePageMaster
Inherits System.Web.UI.MasterPage
Dim _pageTitle As String
Public Property PageTitle() As String
Get
Return _pageTitle
End Get
Set(ByVal value As String)
_pageTitle = value
End Set
End Property
End Class
End Namespace
Sincerely,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Fri, 10 Aug 2007 03:09:20 GMT
Author:
|
Re: Accessing Properties in masterpage from content file
Ok, something must be wrong with the setup, Because when I change the page
directive to Codefile and try to pick the url to the vb file. The dialog box
comes up and only shows the aspx files. If I select to show only code files
the only file that shows is the assembly.info.vb file. I can go directly to
the folder the web project is in, and see that all the .vb files are there.
"Jialiang Ge [MSFT]" wrote in message
news:tpY$fvv2HHA.4200@TK2MSFTNGHUB02.phx.gbl...
> Hello Rick
>
> "Context" is a member of "System.Web.UI.Page". If you do not specify the
> attributes 'CodeFile' and 'Inherits' in the @Page directive correctly, you
> will receive the error: "Context is not a member of PageName.aspx". Please
> check your CodeFile path and the 'Inherits' attribute, and let me know if
> this suggestion could help you resolve the issue.
>
> Besides, the MasterType directive must have exactly one attribute:
> TypeName
> or VirtualPath. Please remove one from your MasterType directive.
>
> Here is my test code for your references:
>
> The structure of the test site:
> Default.aspx
> Default.aspx.vb
> MasterPages\BasePageMaster.master
> MasterPages\BasePageMaster.master.vb
>
> In Default.aspx:
> <%@ Page Language="VB"
> MasterPageFile="~/MasterPages/BasePageMaster.master"
> EnableViewStateMac="false" AutoEventWireup="false"
> CodeFile="~/Default.aspx.vb" Inherits="Digecenter._Default"
> title="Untitled
> Page" %>
> <%@ MasterType VirtualPath="~/MasterPages/BasePageMaster.master" %>
> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
> Runat="Server">
> </asp:Content>
>
> In Default.aspx.vb:
> Namespace Digecenter
> Partial Class _Default
> Inherits System.Web.UI.Page
> Private Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
> Master.PageTitle = "hello world"
> End Sub
> End Class
> End Namespace
>
> In BasePageMaster.master:
> <%@ Master Language="VB" AutoEventWireup="false"
> CodeFile="BasePageMaster.master.vb" Inherits="Digecenter.BasePageMaster"
> %>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
> </asp:contentplaceholder>
> </div>
> </form>
> </body>
> </html>
>
> In BasePageMaster.master.vb
> Namespace Digecenter
> Partial Public Class BasePageMaster
> Inherits System.Web.UI.MasterPage
> Dim _pageTitle As String
> Public Property PageTitle() As String
> Get
> Return _pageTitle
> End Get
> Set(ByVal value As String)
> _pageTitle = value
> End Set
> End Property
> End Class
> End Namespace
>
> Sincerely,
> Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> =================================================
> When responding to posts, please "Reply to Group" via your newsreader
> so that others may learn and benefit from your issue.
> =================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
Date:Fri, 10 Aug 2007 15:06:01 -0500
Author:
|
Re: Accessing Properties in masterpage from content file
Hello Rick,
Because you said that your visual studio only showed the 'AssemblyInfo.vb'
file when you selected to list only code files, would you check to see
whether the vb files have been added into you project? To add the code
files into the project, you should right click your project in the Solution
Explorer, choose 'Add Existing Items' and select your vb files in your
project directory. Then please rebuild your project and let me know if it
works.
If it does not help, I suggest that you may re-create a new test site with
VS's new project wizard, then paste my sample codes in my last reply into
it and see whether your problem can be resolved.
Sincerely,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Mon, 13 Aug 2007 02:29:01 GMT
Author:
|
Re: Accessing Properties in masterpage from content file
All of the vb files are included in the project. Still have same issue, I
tried your test and created a new project(ASPNET Web application) . I still
get the error in the html when using CodeFile:
'Context' is not a member of 'Filenamehere'
"Jialiang Ge [MSFT]" wrote in message
news:GmQ$7GV3HHA.4200@TK2MSFTNGHUB02.phx.gbl...
> Hello Rick,
>
> Because you said that your visual studio only showed the 'AssemblyInfo.vb'
> file when you selected to list only code files, would you check to see
> whether the vb files have been added into you project? To add the code
> files into the project, you should right click your project in the
> Solution
> Explorer, choose 'Add Existing Items' and select your vb files in your
> project directory. Then please rebuild your project and let me know if it
> works.
>
> If it does not help, I suggest that you may re-create a new test site with
> VS's new project wizard, then paste my sample codes in my last reply into
> it and see whether your problem can be resolved.
>
> Sincerely,
> Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> =================================================
> When responding to posts, please "Reply to Group" via your newsreader
> so that others may learn and benefit from your issue.
> =================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
Date:Mon, 13 Aug 2007 16:50:21 -0500
Author:
|
Re: Accessing Properties in masterpage from content file
Hello Rick
When you set the CodeFile attribute in the @Page directive, does the
intelligence of Visual Studio list your vb files besides the button 'Pick
URL '? On my side, when I write 'CodeFile=' in the @Page directive of
Default.aspx, it shows a context menu, which lists 'Default.aspx.vb' and a
'Pick URL' button. Attached is the complete project I tested, would you
try it in your computer, and let me know the result? You need to use
Outlook Express to download the attachment.
If it still does not work on your side, would you mind sending me the test
website project in which you paste my sample codes? I will test it on my
side so as to determine whether it is a problem of your VS setup. Besides,
would you tell me your version of Visual Studio? If it is VS 2003, you will
lose all the intelligence, debugging, drag and drop, etc when you use it to
develop .NET 2.0 projects.
Sincerely,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Tue, 14 Aug 2007 03:50:16 GMT
Author:
|
Re: Accessing Properties in masterpage from content file
Hello Rick,
Have you received my sample project? Would you let me know how does the
project work on your side? If you need further assistance, feel free to
let me know. I will be more than happy to be of assistance.
Have a great day!
Sincerely,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Thu, 16 Aug 2007 01:42:40 GMT
Author:
|
|
|