为侧边栏仪表板创建 Web 用户控件,并为每个项目提供模式弹出窗口
您好,基本上我想创建一个控件,可以将弹出窗口添加到在页面标记中声明的菜单项。我希望语法如下:
<uc1:Sidebar id="" runat="server" enablePopup="True">
<PopUpBindings>
<PopedControlId="" BackgroundClass="" TargetItemIndex=""/>
<PopedControlId="" BackgroundClass="" TargetItemIndex=""/>
..
</PopUpBindings>
</uc1:Sidebar>
我能够使用 asmx 页面中的成员字段创建enablePopUp。如下所示
private bool _enablePopup;
public Boolean EnablePopup
{
get { return _enablePopup; }
set { _enablePopup = value; }
}
,但创建一个绑定集,如标记 1 中所示。以前从未这样做过。有人可以对此给予提示吗? 问题2: 正在创建此用户控件,因为无法与 Repeater 的数据绑定一起创建 modalPopup。我在中继器 ItemDatabound 事件中尝试了以下操作,但会抛出异常“无法找到目标控件 Id ={0}”
mpcpnlNewBp.TargetControlID = e.Item.ID;//open modalpopup
Hi basically i want to create a Control that can add popup to menuItems which is declared in the markup of the page. I would like the syntax to be like below:
<uc1:Sidebar id="" runat="server" enablePopup="True">
<PopUpBindings>
<PopedControlId="" BackgroundClass="" TargetItemIndex=""/>
<PopedControlId="" BackgroundClass="" TargetItemIndex=""/>
..
</PopUpBindings>
</uc1:Sidebar>
I am able to create enablePopUp using Member Fields in the asmx Page. Like Below
private bool _enablePopup;
public Boolean EnablePopup
{
get { return _enablePopup; }
set { _enablePopup = value; }
}
but creating a bindings set as in markUp 1. Never done that before. Could someone give hints to this.
Question 2:
This usercontrol is being created because modalPopup could not be created along with Repeater's Databinding. I tried the below in repeaters ItemDatabound event but would throw exception "Target control Id ={0} could not be found"
mpcpnlNewBp.TargetControlID = e.Item.ID;//open modalpopup
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要的是控件上的集合属性 - 请参阅来自 MSDN 的示例代码来了解一下。
如果需要更多设计器支持,例如用于编辑属性的 UI,那么您需要创建集合编辑器 - 检查
编辑:
对于中继器等模板化控件,需要在正确的父控件上下文中找到目标控件,而模态弹出窗口无法做到这一点。解决方案是在页面/用户控件上使用虚拟(隐藏)控件作为模式弹出窗口的目标控件,然后使用扩展器的 java 脚本 API 根据需要隐藏/显示弹出窗口(请参阅 本文(适用于客户端 API)。
What you need is Collection properties on your control - see this example code from MSDN to get an idea.
If more designer support such as UI for editing properties is needed then you need to create Collection Editor - check this related example.
EDIT:
With templated controls such as repeater, target control needs to be found in the correct parent control context which Modal Popup cannot do. The solution is to use a dummy (hidden) control on the page/user control as a target control for the modal popup and then use extender's java-script API to hide/show popup as per needs (see this article for client side API).