简体   繁体   English

从处理程序动态加载用户控件,并传递属性值

[英]Loading user control dynamically from handler, and passing property values

I'm trying to load a user control using the following example: Load ascx via jQuery我正在尝试使用以下示例加载用户控件: Load ascx via jQuery

The example is using Page.LoadControl(String).该示例使用 Page.LoadControl(String)。 I'd like to load a control that has custom properties, is there a way to pass them using this method?我想加载一个具有自定义属性的控件,有没有办法使用这种方法传递它们?

Thanks in advance.提前致谢。

PS, both the control and handler are new so I am able to start over with a different approach. PS,控件和处理程序都是新的,所以我可以用不同的方法重新开始。

EDIT编辑

OK, so I went about creating a class in the App_Code, and made my control inherit from it.好的,所以我开始在 App_Code 中创建一个 class,并让我的控件继承自它。

Created all properties as MustInherit in the base class.在基础 class 中将所有属性创建为 MustInherit。 And then casted the return from LoadControl method to the BaseClass type, all properties are available.然后将 LoadControl 方法的返回转换为 BaseClass 类型,所有属性都可用。

I'm not sure if it's the cleanest solution or not though.我不确定这是否是最干净的解决方案。

Loading Webcontrol dynamically and pass value动态加载Webcontrol并传递值

http://www.wikipad.info/Details.aspx?ID=71 http://www.wikipad.info/Details.aspx?ID=71

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM