ASP.Net AJAX 模式弹出窗口
首先我将描述 Web 表单布局:
该表单包含一个带有“详细信息”按钮的 GridView1,该按钮可打开第二个 GridView2,其目的当然是显示从父 GridView1 中选择的项目的详细信息。所有控件都在服务器端代码隐藏中动态呈现。
挑战:
我需要创建一个模式弹出窗口,当用户单击子 GridView2 中作为 TemplateField 中的图像控件的图标时,就会显示该窗口。这样用户就可以向子 GridView2 中的详细信息添加注释。
我的方法:
我试图在 PreRender 阶段将 AJAXToolKit 的模态弹出扩展器(ID =“mpe”)连接到 TemplateField 中的图标。由于 TargetControlID 不能为 null 或空,所以我要做的是创建一个虚拟 Button 控件,并将模式弹出扩展程序的 TargetControlID 属性设置为调用的虚拟按钮的 ID,然后在将 TemplateField 添加到 GridView2 后,将 TargetControlID 属性设置为图标的 ID,即“icon_addComment”。
问题:
当我尝试将 TargetControlID 属性设置为图标的 ID 时,代码会抛出错误“‘mpe’的 TargetControlID 无效。ID 为‘icon_addComment’的控件可以找不到。”。我对如何使其正常工作感到困惑,似乎无法绕过必须在模态弹出扩展程序之前创建目标控件的条件。我想要的只是让子 GridView2 图标的 ID 成为模式弹出扩展程序的 TargetControlID
First I'll describe the web form layout:
The form contains a GridView1 with a "Details" button that opens a second GridView2, whose purpose of course is to show details of the item selected from parent GridView1. All controls are rendered dynamically in the server-side codebehind.
The Challenge:
I need to create a modal pop-up window that's presented when the user clicks an icon that's in child GridView2 as an Image control in a TemplateField. This is so users can add comments to the details in child GridView2.
My approach:
I'm trying to get the AJAXToolKit's modal popup extender (ID = "mpe") wired to the icon in the TemplateField during the PreRender stage. Since the TargetControlID cannot be null or empty, what I'm doing is creating a dummy Button control and setting the modal popup extender's TargetControlID property to the dummy button's ID called, then after the TemplateField is added to GridView2, I set the TargetControlID property to the icon's ID, which is "icon_addComment".
The Problem:
When I try to set the TargetControlID property to the icon's ID, the code throws the error "The TargetControlID of 'mpe' is not valid. A control with ID 'icon_addComment' could not be found.". I'm stumped on how I can get this to work properly, it seems there's no way getting around the condition that the Target Control must be created before the modal popup extender. What I'd like is to just have the child GridView2 icon's ID be the TargetControlID for the modal popup extender
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用虚拟隐藏按钮作为模态弹出窗口扩展器的目标控件 ID,然后使用 java 脚本在实际图标单击时显示/隐藏模态弹出窗口。例如,
就我个人而言,我不喜欢ajax控制工具包。对于这个要求,我会使用 jquery UI Dialog。
Use a dummy hidden button as a target control id to the modal popup extender and then use java-script to show/hide the modal pop-up on actual icon click. For example,
Personally, I am not a fan of ajax control toolkit. For this requirement, I would have used jquery UI Dialog.