从模块访问母版页属性 [英] Accessing a Master Page Property from a Module

查看:52
本文介绍了从模块访问母版页属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读斯科特艾伦关于母版页的文章(http://

odetocode.com/Articles/450.aspx)但我遇到了问题

理解一个概念。具体来说,我在我的母版页上创建了一个属性

(称为CurFlag),可以从内容访问
页面,但不能从单独的代码模块访问。


我在VB代码模块中尝试过这样的事情:


将myMaster视为MasterPage = CType(ProjectMgmt.Master,

MasterPage)

myMaster.CurFlag =" value"


....但这只是给我一个参考非共享成员要求

一个对象引用第一行出错。请原谅我的无知,

但是我的语法是正确的,还是我需要在母版页上添加额外的东西,以便我的模块看到这个母版页?


我会很感激任何建议。

谢谢。

I have been reading Scott Allen''s article on Master Pages (http://
odetocode.com/Articles/450.aspx) but I am having problems
understanding a concept. Specifically, I have created a property
(called "CurFlag") on my master page that can be accessed from content
pages, but not from separate code modules.

I tried doing something like this in my VB code module:

Dim myMaster As MasterPage = CType(ProjectMgmt.Master,
MasterPage)
myMaster.CurFlag = "value"

....but this just gets me an "Reference to a non-shared member requires
an object reference" error on the first line. Forgive my ignorance,
but is my syntax correct, or do I need to add something additional to
the master page so that my module "sees" this master page?

I would appreciate any suggestions.
Thank you.

推荐答案

5月24日晚上10点18分,Kirk< lok ... @ hotmail.comwrote:
On May 24, 10:18 pm, Kirk <lok...@hotmail.comwrote:

我一直在读斯科特艾伦在硕士页面上的文章(http://

odetocode.com/Articles/450.aspx)但我遇到了问题

理解一个概念。具体来说,我在我的母版页上创建了一个属性

(称为CurFlag),可以从内容访问
页面,但不能从单独的代码模块访问。


我在VB代码模块中尝试过这样的事情:


将myMaster视为MasterPage = CType(ProjectMgmt.Master,

MasterPage)

myMaster.CurFlag =" value"


...但是这只是给我一个参考非共享成员要求

一个对象引用第一行出错。请原谅我的无知,

但是我的语法是正确的,还是我需要在母版页上添加额外的东西,以便我的模块看到这个母版页?


我会很感激任何建议。

谢谢。
I have been reading Scott Allen''s article on Master Pages (http://
odetocode.com/Articles/450.aspx) but I am having problems
understanding a concept. Specifically, I have created a property
(called "CurFlag") on my master page that can be accessed from content
pages, but not from separate code modules.

I tried doing something like this in my VB code module:

Dim myMaster As MasterPage = CType(ProjectMgmt.Master,
MasterPage)
myMaster.CurFlag = "value"

...but this just gets me an "Reference to a non-shared member requires
an object reference" error on the first line. Forgive my ignorance,
but is my syntax correct, or do I need to add something additional to
the master page so that my module "sees" this master page?

I would appreciate any suggestions.
Thank you.



首先必须将实例声明为对象变量,然后由变量名引用




Dim myMaster As MasterPage = new ProjectMgmt.Master

The instance must first be declared as an object variable and then
referenced by the variable name.

Dim myMaster As MasterPage = new ProjectMgmt.Master


5月24日晚上10点29分,Alexey Smirnov< alexey.smir .. 。@ gmail.comwrote:
On May 24, 10:29 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:

5月24日晚上10点18分,Kirk< lok ... @ hotmail.comwrote:


我一直在阅读Scott Allen关于母版页的文章(http://

odetocode.com/Articles/450 .aspx)但我遇到了问题

理解一个概念。具体来说,我在我的母版页上创建了一个属性

(称为CurFlag),可以从内容访问
页面,但不能从单独的代码模块访问。
I have been reading Scott Allen''s article on Master Pages (http://
odetocode.com/Articles/450.aspx) but I am having problems
understanding a concept. Specifically, I have created a property
(called "CurFlag") on my master page that can be accessed from content
pages, but not from separate code modules.


我在VB代码模块中尝试过这样的事情:
I tried doing something like this in my VB code module:


Dim myMaster As MasterPage = CType(ProjectMgmt.Master,

MasterPage)

myMaster.CurFlag =" value"
Dim myMaster As MasterPage = CType(ProjectMgmt.Master,
MasterPage)
myMaster.CurFlag = "value"


...但这只是给我一个引用非共享成员需要

一个对象引用 ;第一行出错。请原谅我的无知,

但是我的语法是正确的,还是我需要在母版页上添加额外的东西,以便我的模块看到这个母版页?
...but this just gets me an "Reference to a non-shared member requires
an object reference" error on the first line. Forgive my ignorance,
but is my syntax correct, or do I need to add something additional to
the master page so that my module "sees" this master page?


我将不胜感激任何建议。

谢谢。
I would appreciate any suggestions.
Thank you.



首先必须将实例声明为对象变量,然后用变量名引用




Dim myMaster As MasterPage = new ProjectMgmt.Master-隐藏引用文字 -


- 显示引用文字 -


The instance must first be declared as an object variable and then
referenced by the variable name.

Dim myMaster As MasterPage = new ProjectMgmt.Master- Hide quoted text -

- Show quoted text -



等等......必须有一个班级名称


我认为,ProjectMgmt.Master是你母版页面的名称

Wait... there must be a name of the class

I think, ProjectMgmt.Master is the name of your Master page


Kirk,


不确定你想要实现什么 - 为什么你需要访问

主页(一般来说)页面特定 - 因为不同的页面可能有一个模块的不同主页页面?您只需要访问

特定页面的主页面实例 - 在这种情况下,您需要一个

引用页面实例(或任何控件)页面)或主人

本身。


如果您需要更改所有页面的主人 - 在主人内部进行,

你会得到它的参考。


如果你提供更多关于你想要达到的目标,它将更容易

更容易建议一个更好的方法来完成任务。


" Kirk"写道:
Kirk,

Not sure what are you trying to achieve - why would you need to access
master page (which is generally page specific - as different pages may have
different master pages) from a module? You will only want to access a
particular page''s master page instance - in this case you will need a
reference to the page instance (or any control on the page) or to the master
itself.

If you need to change your master for all page - do it inside your Master,
and you will have the reference to it.

If you provide a bit more on what you are trying to achieve, it will be
easier to suggest a better way to accomplish the task.

"Kirk" wrote:

我一直在阅读斯科特艾伦关于母版页的文章(http://

odetocode.com/Articles/ 450.aspx)但我遇到了问题

理解一个概念。具体来说,我在我的母版页上创建了一个属性

(称为CurFlag),可以从内容访问
页面,但不能从单独的代码模块访问。


我在VB代码模块中尝试过这样的事情:


将myMaster视为MasterPage = CType(ProjectMgmt.Master,

MasterPage)

myMaster.CurFlag =" value"


....但这只是给我一个参考非共享成员要求

一个对象引用第一行出错。请原谅我的无知,

但是我的语法是正确的,还是我需要在母版页上添加额外的东西,以便我的模块看到这个母版页?


我将不胜感激任何建议。

谢谢。

I have been reading Scott Allen''s article on Master Pages (http://
odetocode.com/Articles/450.aspx) but I am having problems
understanding a concept. Specifically, I have created a property
(called "CurFlag") on my master page that can be accessed from content
pages, but not from separate code modules.

I tried doing something like this in my VB code module:

Dim myMaster As MasterPage = CType(ProjectMgmt.Master,
MasterPage)
myMaster.CurFlag = "value"

....but this just gets me an "Reference to a non-shared member requires
an object reference" error on the first line. Forgive my ignorance,
but is my syntax correct, or do I need to add something additional to
the master page so that my module "sees" this master page?

I would appreciate any suggestions.
Thank you.


这篇关于从模块访问母版页属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆