从用户控件访问基页类? [英] access the base Page class from user controls??

查看:58
本文介绍了从用户控件访问基页类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人告诉我如何创建我的顶级

级别(基础)页面类的实例,以便我可以从用户访问它的对象

控制?有人告诉我


public myParent =(default_aspx)this.Page;


其中default_aspx是基页的类名...

Please can someone tell me how on earth to create an instance of my top
level (base) Page class so that I can access it''s objects from an user
control?? Someone told me

public myParent = (default_aspx) this.Page;

where default_aspx is the class name of the base Page...

推荐答案

我创建了一个用户控件基类,它执行以下操作:

public new MyBasePage Page {

得到{return(MyBasePage)this.Page; }

}


我在这个地方使用这个。

当然(MyBasePage)this.Page也可以。< br $>

祝你好运,

Jeffrey Palermo


"DavíeTórisson" <分贝** @ hi.is>在留言中写道

新闻:e6 ************** @ TK2MSFTNGP10.phx.gbl ...
I make a User Control base class that does the following:
public new MyBasePage Page{
get { return (MyBasePage)this.Page; }
}

I use this all over the place.
of course (MyBasePage)this.Page works too.

Best regards,
Jeffrey Palermo

"Davíe Tórisson" <db**@hi.is> wrote in message
news:e6**************@TK2MSFTNGP10.phx.gbl...
请有人能告诉我如何创建我的顶级
级别(基础)页面类的实例,以便我可以从用户访问它的对象
控件?有人告诉我

public myParent =(default_aspx)this.Page;

其中default_aspx是基页的类名...
Please can someone tell me how on earth to create an instance of my top
level (base) Page class so that I can access it''s objects from an user
control?? Someone told me

public myParent = (default_aspx) this.Page;

where default_aspx is the class name of the base Page...



杰弗里你能不能看看这里,因为这让我开车...

这是我在Initialise.aspx中的代码.cs(用户控件),错误

我得到的是CS1513:}预期


使用系统;

使用System.Web;

使用System.Web.UI;

使用System.Web.UI.WebControls;

使用System.Web .UI.HtmlControls;


公共部分类Initialise_ascx

{

void Page_Load(object sender,System.EventArgs e)

{

public new MyBasePage Page

{

get {return(MyBasePage)this.Page; }

}

MyBasePage.myLiteral.Text =" asdafds";

}

}

" Jeffrey Palermo [MCP]" < HTTP://dotnetjunkies.com/weblog/jpalermo>写在

消息新闻:eF ************** @ TK2MSFTNGP14.phx.gbl ...
Jeffrey could you please take a look here since this is driving me cray...
this is the code I have in Initialise.aspx.cs (the user control), the error
I get is "CS1513: } expected"

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class Initialise_ascx
{
void Page_Load(object sender, System.EventArgs e)
{
public new MyBasePage Page
{
get { return (MyBasePage)this.Page; }
}
MyBasePage.myLiteral.Text = "asdafds";
}
}
"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
message news:eF**************@TK2MSFTNGP14.phx.gbl...
我做了一个用户控件执行以下操作的基类:
public new MyBasePage Page {
get {return(MyBasePage)this.Page; }


我在整个地方使用它。
当然(MyBasePage)this.Page也可以。

致以最好的问候,

DavíeTórisson <分贝** @ hi.is>在消息中写道
新闻:e6 ************** @ TK2MSFTNGP10.phx.gbl ...
I make a User Control base class that does the following:
public new MyBasePage Page{
get { return (MyBasePage)this.Page; }
}

I use this all over the place.
of course (MyBasePage)this.Page works too.

Best regards,
Jeffrey Palermo

"Davíe Tórisson" <db**@hi.is> wrote in message
news:e6**************@TK2MSFTNGP10.phx.gbl...
请有人能告诉我怎么样创建我的顶级
级别(基础)页面类的实例,以便我可以从用户访问它的对象
控件?有人告诉我

public myParent =(default_aspx)this.Page;

其中default_aspx是基页的类名...
Please can someone tell me how on earth to create an instance of my top
level (base) Page class so that I can access it''s objects from an user
control?? Someone told me

public myParent = (default_aspx) this.Page;

where default_aspx is the class name of the base Page...




您好Davíe:


您在方法中定义了属性。我觉得你在寻找的是



使用系统;

唱System.Web;

使用System.Web.UI;

使用System.Web.UI.WebControls;

使用System.Web.UI.HtmlControls;


public partial class Initialise_ascx

{

void Page_Load(object sender,System.EventArgs e)

{

MyBasePage.myLiteral.Text =" asdafds";

}

public new MyBasePage Page

{

得到{return(MyBasePage)this.Page; }

}

}


现在在Page_Load中,你将调用Page属性来

检索对基页的引用。


HTH,


-

Scott
http://www.OdeToCode.com/blogs/scott/


2004年10月27日星期三13:08:06 -0000,DavíeTórisson < db ** @ hi.is>

写道:
Hi Davíe:

You have a property defined inside of a method. I think what you are
looking for is:

using System;
sing System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class Initialise_ascx
{
void Page_Load(object sender, System.EventArgs e)
{
MyBasePage.myLiteral.Text = "asdafds";
}
public new MyBasePage Page
{
get { return (MyBasePage)this.Page; }
}
}

Now inside of Page_Load, you''ll be calling the Page property to
retrieve a reference to the base page.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 27 Oct 2004 13:08:06 -0000, "Davíe Tórisson" <db**@hi.is>
wrote:
杰弗里你能不能看看这里,因为这让我开车... <这是我在Initialise.aspx.cs(用户控件)中的代码,我得到的错误是CS1513:}预期的

使用System; 使用System.Web.UI.WebControls;
使用System.Web.UI.HtmlControls;

public partial class Initialise_ascx
{
void Page_Load(object sender,System.EventArgs e)
{public public MyBasePage Page
{
get { return(MyBasePage)this.Page; }
} MyBasePage.myLiteral.Text =" asdafds";
}
}

" Jeffrey Palermo [MCP]" < HTTP://dotnetjunkies.com/weblog/jpalermo>在
消息新闻中写道:eF ************** @ TK2MSFTNGP14.phx.gbl ...
Jeffrey could you please take a look here since this is driving me cray...
this is the code I have in Initialise.aspx.cs (the user control), the error
I get is "CS1513: } expected"

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class Initialise_ascx
{
void Page_Load(object sender, System.EventArgs e)
{
public new MyBasePage Page
{
get { return (MyBasePage)this.Page; }
}
MyBasePage.myLiteral.Text = "asdafds";
}
}
"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
message news:eF**************@TK2MSFTNGP14.phx.gbl...
我创建了一个用户控件基类以下内容:
public new MyBasePage Page {
get {return(MyBasePage)this.Page; }


我在整个地方使用它。
当然(MyBasePage)this.Page也可以。

致以最好的问候,

DavíeTórisson <分贝** @ hi.is>在消息中写道
新闻:e6 ************** @ TK2MSFTNGP10.phx.gbl ...
I make a User Control base class that does the following:
public new MyBasePage Page{
get { return (MyBasePage)this.Page; }
}

I use this all over the place.
of course (MyBasePage)this.Page works too.

Best regards,
Jeffrey Palermo

"Davíe Tórisson" <db**@hi.is> wrote in message
news:e6**************@TK2MSFTNGP10.phx.gbl...
请有人能告诉我怎么样创建我的顶级
级别(基础)页面类的实例,以便我可以从用户访问它的对象
控件?有人告诉我

public myParent =(default_aspx)this.Page;

其中default_aspx是基页的类名...
Please can someone tell me how on earth to create an instance of my top
level (base) Page class so that I can access it''s objects from an user
control?? Someone told me

public myParent = (default_aspx) this.Page;

where default_aspx is the class name of the base Page...







这篇关于从用户控件访问基页类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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