参考页面控件来自类 [英] Reference Page Controls From Class

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

问题描述

如何引用页面或用户控件的属性(例如viewstate)

和来自其他类的控件?


TIA


-


Alphonse Giambrone

电子邮件:a-giam at customdatasolutions dot us

How can I reference a page or user control''s properties (such as viewstate)
and controls from another class?

TIA

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us

推荐答案



您必须继承控件才能访问ViewState之类的东西。对于

示例,您希望扩展您要执行的页面类:


公共类ExtendedPage:System.Web.UI.Page

我不确定这是不是你问的问题,但这是我所理解的

你的问题

-

Abdellah Elamiri

..net开发商

通过简单实现的功效

Alphonse Giambrone < NO ********** @ example.invalid>在消息中写道

新闻:e2 ************* @ TK2MSFTNGP09.phx.gbl ...

You have to inherit the control to access things like the ViewState. For
example you want to extend the page class you would do:

public class ExtendedPage : System.Web.UI.Page
I''m not sure if that''s what you''re asking but that''s what I understood from
your question
--
Abdellah Elamiri
..net Developer
Efficacy through simplicity
"Alphonse Giambrone" <NO**********@example.invalid> wrote in message
news:e2*************@TK2MSFTNGP09.phx.gbl...
如何引用页面或者用户控制'的属性(例如
viewstate)和来自另一个类的控件?

TIA

-

Alphonse Giambrone
电子邮件:a-giam at customdatasolutions dot us
How can I reference a page or user control''s properties (such as viewstate) and controls from another class?

TIA

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us



您好Alphonse,


从您的描述中,您的意思是如何引用一个页面或用户控件来自另一个类的
,这个类是否意味着一个类似于想要与b
隔离的实用类与网络相关的信息?


如果是这样,我认为有两种方法可以选择:

1.在某个类中定义一个函数,其中包含一个param类型

其中Page是或UserControl那么,你可以参考某些

页面或UserControl的成员:例如:

公共类...

public void processPage (页面页)

{

page.XXX。 = xxxx;

}


public void processUserControl(UserControl uc)

{

uc。 xxxx = xxx;

}

2.在ASP.NET web应用程序中,HttpContext.Current静态成员提供

对当前处理的引用请求'上下文,如果

请求'的处理程序是一个Page处理程序(或者从
System.Web.UI.Page派生的其他类),我们可以使用HttpContext.Current.Handler获取

当前页面的引用,例如:


public void processPage()

{

页页=(页)HttpContext.Current.Handler;

page.XXX = xxx;

}


另外,这里有一些前线程讨论类似的

问题:

http://groups.google .com / groups?hl = e ... readm = I5%24opc
HGEHA.616%40cpmsftngxa06.phx.gbl& rnum = 1& prev = / groups%3Fhl%3Den%26lr%3D%26ie%

3DUTF-8%26oe%3DUTF- 8%26q%3Dasp.net%2Bpage%2B来自%2Bclass%2B%2Bsteven%2Bcheng

http://groups.google.com/groups?hl=e...readm = wAVBte%2

4CEHA.564%40cpmsftngxa06.phx.gbl& rnum = 13& prev = / groups%3Fq%3D%2Bpage%2Bmember

%2Bsteven%2Bcheng%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26start%3D10%2

6sa%3DN


希望也有帮助。谢谢。


问候,


Steven Cheng

微软在线支持


安全! www.microsoft.com/security

(此帖子按原样提供,不作任何保证,并且不授予

权利。)


在ASP.NET上获取预览whidbey
< a rel =nofollowhref =http://msdn.microsoft.com/asp.net/whidbey/default.aspxtarget =_ blank> http://msdn.microsoft.com/asp.net/whidbey /default.aspx

Hi Alphonse,

From your description, you means how to reference a page or user control
from another class, does the class you mean a utilitiy class which want to
be isolated with the web related infos?

If so, I think there are two means you can choose:
1. Define a function in the certain class which contains a param the type
of which is "Page" or "UserControl" then, you can reference the certain
Page or UserControl''s members: For example:
public class ...
public void processPage(Page page)
{
page.XXX. = xxxx;
}

public void processUserControl(UserControl uc)
{
uc.xxxx = xxx;
}
2. In ASP.NET web applicatoin the HttpContext.Current static member provide
the reference to the current processed Request''s Context and if the
request''s handler is a Page handler(or other classes derived from
System.Web.UI.Page), we can use the HttpContext.Current.Handler to get the
Current Page''s reference ,such as:

public void processPage()
{
Page page = (Page)HttpContext.Current.Handler;
page.XXX = xxx;
}

In addtion, here are some former threads discussing on the similar
questions:

http://groups.google.com/groups?hl=e...readm=I5%24opc
HGEHA.616%40cpmsftngxa06.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%
3DUTF-8%26oe%3DUTF-8%26q%3Dasp.net%2Bpage%2Bfrom%2Bclass%2B%2Bsteven% 2Bcheng

http://groups.google.com/groups?hl=e...readm=wAVBte%2
4CEHA.564%40cpmsftngxa06.phx.gbl&rnum=13&prev=/groups%3Fq%3D%2Bpage%2Bmember
%2Bsteven%2Bcheng%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26start%3D10%2
6sa%3DN

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx



感谢您的回复。


It看起来你已经为我钉了它Steven。


我应该提到我在VB.NET工作。虽然我很熟悉

的一些c#语法,但我不太明白以下几行:

Page page =(Page)HttpContext.Current.Handler;

VB中的等价物是什么?


另外,使用方法1与方法2的性能有何不同?


-


Alphonse Giambrone

电子邮件:a-giam at customdatasolutions dot us

" Steven程[MSFT] QUOT; <,V - ****** @ online.microsoft.com>在留言中写道

新闻:K9 ************** @ cpmsftngxa06.phx.gbl ...
Thanks both for the replies.

It looks like you have nailed it for me Steven.

I should have mentioned that I am working in VB.NET. While I am familiar
with some of the c# syntax, I don''t quite understand the following line:
Page page = (Page)HttpContext.Current.Handler;
What would be the equivalent in VB?

Also, is there any difference in performance using method 1 vs. method 2?

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:K9**************@cpmsftngxa06.phx.gbl...
嗨Alphonse,

从你的描述中,你的意思是如何从另一个类引用一个页面或用户控件,你所说的类是一个想要与web相关信息隔离的实用类如果是这样,我认为有两种方法可以选择:
1.在某个类中定义一个函数,该函数包含一个类型为
的参数。页面"或UserControl那么,你可以参考某些
页面或UserControl的成员:例如:
公共类......
public void processPage(页面页)
{
page.XXX。 = xxxx;
}
公共void processUserControl(UserControl uc)
{
uc.xxxx = xxx;
}

2.在ASP.NET Web应用程序中,HttpContext.Current静态成员
提供对当前处理的请求的上下文的引用,以及
请求的处理程序是否为页面处理程序(或其他)派生自System.Web.UI.Page的类,我们可以使用HttpContext.Current.Handler获取
当前页面的参考,例如:

public void processPage()
{
Page page =(Page)HttpContext.Current.Handler;
page.XXX = xxx;
}

添加,这里有一些前线程讨论类似的问题:

http://groups.google.com/groups?hl=e...readm=I5 %24opc
HGEHA.616%40cpmsftngxa06.phx.gbl& rnum = 1& prev = / groups%3Fhl%3Den%2 6lr%3D%26ie%
3DUTF-8%26oe%3DUTF-8%26q%3Dasp.net%2Bpage%2Bfrom%2Bclass%2B%2Bsteven%2Bcheng
http:// groups .google.com / groups?hl = e ... readm = wAVBte%2
4CEHA.564%40cpmsftngxa06.phx.gbl& rnum = 13& prev = / groups%3Fq%3D%2Bpage %2B成员
%2Bsteven%2Bcheng%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26start%3D10%2 6sa%3DN

希望也有帮助。谢谢。

问候,

Steven Cheng
微软在线支持

获得安全! www.microsoft.com/security
(此帖已提供按原样,没有任何保证,也没有授予
权利。)

在ASP.NET上预览whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Alphonse,

From your description, you means how to reference a page or user control
from another class, does the class you mean a utilitiy class which want to
be isolated with the web related infos?

If so, I think there are two means you can choose:
1. Define a function in the certain class which contains a param the type
of which is "Page" or "UserControl" then, you can reference the certain
Page or UserControl''s members: For example:
public class ...
public void processPage(Page page)
{
page.XXX. = xxxx;
}

public void processUserControl(UserControl uc)
{
uc.xxxx = xxx;
}
2. In ASP.NET web applicatoin the HttpContext.Current static member provide the reference to the current processed Request''s Context and if the
request''s handler is a Page handler(or other classes derived from
System.Web.UI.Page), we can use the HttpContext.Current.Handler to get the
Current Page''s reference ,such as:

public void processPage()
{
Page page = (Page)HttpContext.Current.Handler;
page.XXX = xxx;
}

In addtion, here are some former threads discussing on the similar
questions:

http://groups.google.com/groups?hl=e...readm=I5%24opc HGEHA.616%40cpmsftngxa06.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie% 3DUTF-8%26oe%3DUTF-8%26q%3Dasp.net%2Bpage%2Bfrom%2Bclass%2B%2Bsteven% 2Bcheng
http://groups.google.com/groups?hl=e...readm=wAVBte%2 4CEHA.564%40cpmsftngxa06.phx.gbl&rnum=13&prev=/groups%3Fq%3D%2Bpage%2Bmember %2Bsteven%2Bcheng%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26start%3D10%2 6sa%3DN

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx



这篇关于参考页面控件来自类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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