从Usercontrol传递数据 [英] Passing data from Usercontrol
本文介绍了从Usercontrol传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在WebForm上有一个Usercontrol,这个Usercontrol是一个按钮,我想要
来保存当用户点击按钮时驻留在WebForm上的数据
'在UserControl上。
如何通过button_click事件调用WebForm中的方法或者
来自来自UserControl的任何其他事件?
Peter
-
谢谢
- ------------------
cz **** @ wsinc.com
I have an Usercontrol on a WebForm, on this Usercontrol is a button, I want
to save data that''s residing on the WebForm when user clicks on the button
that''s on the UserControl.
How do I call a method that''s in the WebForm from the button_click event or
from any other event that originate in the UserControl?
Peter
--
Thanks
-------------------
cz****@wsinc.com
推荐答案
您可以通过用户控件公开属性。在运行时...你可以为它分配值。
这里有详细的文章可以在这里找到。
http://radio.weblogs.com/0101986/sto...ercontrols.htm
希望这个帮助
Avnees
MCAD,MCSD.Net
You can expose properties from your User Control. At run time ...you can assign values to the same.
A detailed article on the same can be found here.
http://radio.weblogs.com/0101986/sto...ercontrols.htm
Hope this help
Avnees
MCAD, MCSD.Net
试试这个...
((URNameSpace.URWebFormName)this.Parent).UrFunctio n();
将URNameSpace替换为WebForm的名称空间
将URWebFormName替换为控件所在的Web表单名称。
UrFunction是函数名称
"彼得" < CZ **** @ wsinc.com>在消息中写道
news:un ************** @ TK2MSFTNGP09.phx.gbl ...
Try this...
((URNameSpace.URWebFormName)this.Parent).UrFunctio n();
Replace URNameSpace with the name space of WebForm
Replace URWebFormName with The web form Name in which control reside.
UrFunction is the Function name
"Peter" <cz****@wsinc.com> wrote in message
news:un**************@TK2MSFTNGP09.phx.gbl...
我有一个Usercontrol on一个WebForm,在这个Usercontrol上是一个按钮,I
想要保存当用户点击UserControl上的按钮时驻留在WebForm上的数据。
<如何从button_click事件
或源自UserControl的任何其他事件中调用WebForm中的方法?
Peter
-
谢谢
-------------------
cz****@wsinc.com
I have an Usercontrol on a WebForm, on this Usercontrol is a button, I want to save data that''s residing on the WebForm when user clicks on the button
that''s on the UserControl.
How do I call a method that''s in the WebForm from the button_click event or from any other event that originate in the UserControl?
Peter
--
Thanks
-------------------
cz****@wsinc.com
感谢您的帮助,看起来像我需要的,谢谢非常为
提供一个例子!
" Steven Cheng [MSFT]" <,V - ****** @ online.microsoft.com>在消息中写道
news:BR ************** @ cpmsftngxa07.phx.gbl ...
Thank you for your help, looks like this what I need and thank very much for
supplying an example!
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:BR**************@cpmsftngxa07.phx.gbl...
嗨彼得,
感谢您在社区中发帖!
从您的描述中,您有一个ASP.NET UserControl,它有一个按钮。
当UserControl被放入某个ASP时在.NET页面中,你想从容器页面中调用某个方法或事件
处理程序来自
Button(在UserControl中)的点击事件,是吗?
如果有什么我误解了,请随时告诉我。
至于这个问题,我认为您可以尝试在UserControl中公开一个公共事件处理程序
,然后在其容器页面中检索usercontrol'的Page_Load事件并将此处理程序成员设置为Contaner页面的处理程序成员函数之一。为了清楚地说明这一点,我已经制作了一个示例页面和
usercontrol以显示上述方法,并且我已将源文件附加到
此消息中。
另外,我查看了Avneesh提供的网络链接。那也就这个问题进行了讨论,如果你觉得有什么不清楚的话,你也可以对它有所了解。
请试试前面的建议。如果您有任何疑问,请随时告诉我们。
问候,
Steven Cheng
Microsoft在线支持
<获得安全! www.microsoft.com/security
(此帖已提供按原样,没有任何保证,也没有授予
权利。)
在ASP.NET上预览whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
这篇关于从Usercontrol传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文