我可以在模态弹出窗口内进行编辑吗?

发布于 2024-12-12 08:42:55 字数 3283 浏览 0 评论 0原文

我只发现使用网格视图和模式弹出窗口的人需要编辑帮助的帖子。但是,我没有使用 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

更新:我创建了第二个用于编辑的模式弹出窗口,并将标签更改为文本框,以从数据库中提取信息进行编辑。我添加了一个提交按钮,但是当我单击它时,我收到一条错误消息,指出它有潜在危险。

有没有人有过从客户端检测到潜在危险的Request.Form值的经验

I have only found posts in which people using gridviews and modal popups need help with editing. However, I am not using a gridview so editing is not as simple as an edit within a gridview. The modal popup disappears when I click on the edit button. Here is what I have so far, but in the codebehind I get an error saying that my modal isn't declared.

In the image below, the little pencil image next to the close button is what I click on to edit the description. When I click on it, the modal disappears, so I cannot edit the text.

<!-- 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

enter image description here

UPDATE: i changed the codebehind, but I still get an error saying ViewDescriptionModal is not declared.

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

UPDATE: I have created a second modal popup for edits and changed the Label to a Textbox to pull in information from the database to edit. I added a submit button, but when I click on it, I get an error saying something about it being potentially dangerous.

Does anyone have any experience with A potentially dangerous Request.Form value was detected from the client

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅忆流年 2024-12-19 08:42:55

我还没有对此进行测试,但是如果您使用两个 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>

I haven't tested this, but you may have luck if you use two modalpopupextenders, and two panels, one for viewing and one for editing.

<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>
新人笑 2024-12-19 08:42:55

尝试使用您的图片按钮
autopostback="false"

try in your image button
autopostback="false"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文