【发布时间】:2011-10-27 14:43:37
【问题描述】:
我只发现使用网格视图和模式弹出窗口的人需要帮助进行编辑的帖子。但是,我没有使用网格视图,因此编辑并不像在网格视图中进行编辑那么简单。当我单击编辑按钮时,模式弹出窗口消失。这是我到目前为止所拥有的,但在代码隐藏中我收到一条错误消息,指出我的模态未声明。
在下图中,关闭按钮旁边的小铅笔图像是我单击以编辑描述的地方。当我点击它时,模式消失了,所以我无法编辑文本。
<!-- 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
更新:我为编辑创建了第二个模式弹出窗口,并将标签更改为文本框以从数据库中提取信息进行编辑。我添加了一个提交按钮,但是当我单击它时,我收到一条错误消息,说明它存在潜在危险。
有没有人有A potentially dangerous Request.Form value was detected from the client的经验
【问题讨论】:
-
我不确定您页面的其余部分是什么样的。从这里很难看出你在做什么。
-
@MitchelSellers 我添加了一张图片和更多代码。我希望这有助于更好地解释。
-
我已经读到使用
UpdatePanel将有助于防止模式刷新,但是当我尝试包含它时,我收到一个错误,提示面板不能在UpdatePanel内
标签: vb.net edit modalpopupextender