asp.net - How to call a ASPxControl using ASPxMenu's OnItemClick? C#
问题描述
I have a ASPxMenu that I have named "mnuCategoryOptions" and it has 4 items and I also have ASPxPopupControl that I have named "popupAddProductCategory". When I click one of the items in the ASPxMenu I want it to bring up the ASPxPopupControl. I have written my code in the following way and it does not work:
<dx:ASPxMenu ID="mnuCategoryOptions" runat="server" OnItemClick="mnuCategoryOptions_ItemClick">
<ClientSideEvents ItemClick="function(s, e)
{
e.processOnServer = false;
if (e.item.name == 'mnuAddCategory') { popupAddProductCategory.Show = true; }
else if (e.item.name == 'mnuEditCategory') { alert('Edit Category'); }
else if (e.item.name == 'mnuDeleteCategory') { alert('Del Category'); }
else if (e.item.name == 'mnuAddProducts') { alert('Add Products'); }
else { e.processOnServer = true; }
}" />
<Items>
<dx:MenuItem Name="mnuAddCategory" Text="Add Category"><Image Url="~/images/GridIcons/add.png"/></dx:MenuItem>
<dx:MenuItem Name="mnuEditCategory" Text="Edit Category"><Image Url="~/images/GridIcons/page_edit.png"/></dx:MenuItem>
<dx:MenuItem Name="mnuDeleteCategory" Text="Delete Category"><Image Url="~/images/GridIcons/delete.png"/></dx:MenuItem>
<dx:MenuItem Name="mnuAddProducts" Text="Add Products"><Image Url="~/images/GridIcons/page_add.png" /></dx:MenuItem>
</Items>
</dx:ASPxMenu>
Please look at the line "if (e.item.name == 'mnuAddCategory') { popupAddProductCategory.Show = true; }". This is the line that is not working. Please help.
Kind Regards Siyabonga Kubeka
解决方案
假设你有这样的ASPxPopupControl
服务器控制:
<dx:ASPxPopupControl ID="popupAddProductCategory" runat="server" ClientInstanceName="popupAddProductCategory" ... />
然后你应该使用Show()
方法来显示带有客户端代码的弹出窗口:
if (e.item.name == 'mnuAddCategory') {
popupAddProductCategory.Show();
}
根据ASPxClientPopupControlBase member list,Show
是方法的名称,而不是属性。如果您想使用与控件名称相同的客户端名称,则还ClientInstanceName
必须使用来自弹出控件的属性。
参考:
推荐阅读
- r - 将不同数量的输入作为 r 中的列表传递给函数(应用程序:plot_summs)
- linux - nifi docker无法安装sudo
- python - 关于 Python vs C++ 和 Java 中的类变量的问题
- c - 尝试初始化结构数组时出现段错误
- video - 如何在切割 MP4 文件的一部分后确定 MP4 文件中哪些偏移量发生了变化
- html - Css - 根据第一个孩子的身高拉伸父块并防止根据第二个孩子的身高拉伸
- git - Git Push 挂起写入对象
- scala - 如何根据火花scala中的N值复制记录
- javascript - 第二次单击后模态未显示在我的反应 boostrap 表中
- sql - 避免对以下查询进行索引扫描?