我只发现使用网格视图和模态弹出窗口的人需要编辑帮助的帖子。但是,我没有使用gridview,因此编辑不像gridview中的编辑那么简单。单击编辑按钮时,模态弹出窗口消失。这是我到目前为止所做的,但在代码隐藏中我得到一个错误,说我的模态没有被声明。
在下图中,关闭按钮旁边的小铅笔图像是我点击编辑描述的内容。当我点击它时,模态消失,所以我无法编辑文本。
<!-- Descriptions -->
<asp:TabPanel ID="tab2" runat="server" HeaderText="Descriptions">
<HeaderTemplate>Descriptions</HeaderTemplate>
<ContentTemplate>
<ul class="info">
<asp:ListView ID="lvDescriptions" runat="server"
DataSourceID="dsAdminMarketingDescriptions" DataKeyNames="MarketingID">
<ItemTemplate>
<li class="item">
<asp:LinkButton ID="ViewDescriptionButton" runat="server"><%#
Eval("Title")%>
</asp:LinkButton>
<asp:ImageButton ID="DeleteDescriptionButton" runat="server"
Style="float:right;" AlternateText=""
ImageUrl="../../images/delete.png" CommandName="Delete"
OnClientClick="return confirm('Are you sure you want to delete this
description?')" />
<asp:Panel ID="ViewDescriptionPanel" runat="server"
CssClass="DescModalPopup">
<div class="PopupHeader">View Description -- <%#Eval("Title") %>
<asp:ImageButton ID="CancelDescriptionButton" runat="server"
ImageUrl="../../images/cancel.png" AlternateText=""
Style="float:right;"/>
<asp:ImageButton ID="EditDescriptionButton" runat="server"
ImageUrl="../../images/edit.png" AlternateText=""
Style="float:right;" CommandName="edit" AutoPostBack="false" />
</div>
<asp:Label ID="Description" runat="server" style="padding:2px;">
<%# Eval("Data")%>
</asp:Label>
</asp:Panel>
<asp:ModalPopupExtender ID="ViewDescriptionModal" runat="server"
BackgroundCssClass="modalBackground" DropShadow="false"
DynamicServicePath="" Enabled="true"
PopupControlID="ViewDescriptionPanel"
TargetControlID="ViewDescriptionButton"
CancelControlID="CancelDescriptionButton">
</asp:ModalPopupExtender>
</li>
</ItemTemplate>
Protected Sub EditDescriptionButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
ViewDescriptionModal.Show()
End Sub
更新:我改变了代码隐藏,但我仍然收到一条错误,说没有声明ViewDescriptionModal。
Protected Sub EditDescriptionButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim myControl As Control = FindControl("ViewDescriptionModal")
If (Not myControl Is Nothing) Then
ViewDescriptionModal.Show()
Else
'Control not found
End If
End Sub
更新:我为编辑创建了第二个模态弹出窗口,并将Label更改为文本框以从数据库中提取信息进行编辑。我添加了一个提交按钮,但是当我点击它时,我收到一个错误,说明它有潜在危险。
有没有人有A potentially dangerous Request.Form value was detected from the client
答案 0 :(得分:0)
尝试使用图片按钮
autopostback="false"
答案 1 :(得分:0)
我还没有对此进行过测试,但是如果您使用两个modalpopupextenders和两个面板,一个用于查看,一个用于编辑,您可能会有运气。
<asp:ModalPopupExtender ID="ViewDescriptionModal" runat="server"
BackgroundCssClass="modalBackground" DropShadow="false"
DynamicServicePath="" Enabled="true"
PopupControlID="ViewDescriptionPanel"
TargetControlID="ViewDescriptionButton"
CancelControlID="CancelDescriptionButton">
</asp:ModalPopupExtender>
<asp:ModalPopupExtender ID="EditDescriptionModal" runat="server"
BackgroundCssClass="modalBackground" DropShadow="false"
DynamicServicePath="" Enabled="true"
PopupControlID="EditDescriptionPanel"
TargetControlID="EditDescriptionButton">
</asp:ModalPopupExtender>
<asp:Panel ID="ViewDescriptionPanel" runat="server" ... </asp:panel>
<asp:Panel ID="EditDescriptionPanel" runat="server" ... </asp:Panel><code>