Vb.net 我可以在模式弹出窗口内编辑吗?
我只在一些帖子中发现,使用GridView和模态弹出窗口的人需要编辑方面的帮助。但是,我并没有使用gridview,所以编辑并不像在gridview中进行编辑那样简单。当我点击编辑按钮时,模式弹出窗口消失。这是我到目前为止得到的,但是在代码背后我得到一个错误,说我的模态没有声明Vb.net 我可以在模式弹出窗口内编辑吗?,vb.net,edit,modalpopupextender,Vb.net,Edit,Modalpopupextender,我只在一些帖子中发现,使用GridView和模态弹出窗口的人需要编辑方面的帮助。但是,我并没有使用gridview,所以编辑并不像在gridview中进行编辑那样简单。当我点击编辑按钮时,模式弹出窗口消失。这是我到目前为止得到的,但是在代码背后我得到一个错误,说我的模态没有声明 Protected Sub EditDescriptionButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim myContr
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
在下图中,关闭按钮旁边的小铅笔图像是我单击以编辑描述的内容。当我点击它时,模态消失,因此我无法编辑文本
<!-- 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
更新:我为编辑创建了第二个模式弹出窗口,并将标签更改为文本框,以便从数据库中提取信息进行编辑。我添加了一个提交按钮,但当我点击它时,我得到一个错误,说它有潜在的危险
是否有人有过潜在危险请求的经验。从客户端检测到表单值尝试图像按钮autopostback=false我还没有测试过这一点,但如果您使用两个ModalPopupExtender和两个面板,一个用于查看,一个用于编辑,您可能会很幸运
<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>
我不确定你页面的其他部分是什么样子。很难说你在这里做什么。@Mitchelli添加了一个图像和一点代码。我希望这有助于更好地解释。我已经读到使用UpdatePanel将有助于保持模态不刷新,但是当我尝试包含它时,我收到一个错误,说面板不能在更新面板中。我尝试过,但当我单击按钮时,模式仍然消失。ViewDescriptionModel.visble='true'在按钮单击事件中可能会对您有所帮助。我仍然收到一个错误,说ViewDescriptionModel未声明。这对我来说没有意义,因为这是aspx页面上的ID。是否有我看不到的错误?请使用findcontrol方法。我使用findcontrol方法使用的代码编辑了原始帖子,但仍然得到相同的错误。听起来似乎有道理。我想象我只是在viewmodal中保持编辑按钮的位置。我创建了一个editmodal,但是当我点击编辑按钮时,它不应该打开editmodal吗?再一次,我得到一个错误,说模态没有声明。我做了一个快速测试,它对我有效,尽管我的第二个模态中只有一个测试字符串。您是否仍在使用EditDescriptionButton单击事件?因为它被设置为TargetControlID,所以你不需要在代码隐藏中处理它。是的,我去掉了代码隐藏,当我在模态中点击小铅笔图像时,它只刷新页面,模态消失。你怎么能让编辑模式显示出来?好吧,没关系,一定是打字错误。第二种模式确实出现了。添加一个额外的编辑我的信息的好主意!现在我需要弄清楚如何使文本可编辑,我已经准备好了!