【问题标题】:How do I fill a form using a modal popup?如何使用模式弹出窗口填写表格?
【发布时间】:2012-12-11 01:43:03
【问题描述】:

我有一个带有一堆文本框(街道、号码、城市、邮政编码等)和一个 AJAX modal-popup-extender 的 asp.net 地址表单。

按下按钮时,会显示一个地址簿(在模式弹出窗口中),用户可以在其中搜索和选择他的注册地址之一。这个列表是使用 GridView 实现的,效果很好。每行都有一个这样的链接按钮:

<asp:LinkButton ID="AddressNameLinkButton" runat="server"
                CausesValidation="false"
                CommandArgument='<%# Container.DataItem("ADDRESS_ID") %>'
                CommandName="Select"
                Text='<%# Eval("ADDRESS_NAME")%>' />

按下按钮时,此代码隐藏运行:

Protected Sub AddressGridView_RowCommand(...) Handles AddressGridView.RowCommand
    Dim ADDRESS_ID As Long = e.CommandArgument
    If e.CommandName.CompareTo("Select") = 0 Then
        'Some code that retrieves the information 
        'of the selected address goes here.
        CityTextBox.Text = City
        PostalCodeTextBox.Text = PostalCode
        'Etc. Etc.
        SearchModalPopupExtender.Hide()
    End If
End Sub

问题是,虽然这段代码隐藏了模式弹出窗口,但它并没有填写地址表单。

如何从模式弹出窗口中填写表单?

【问题讨论】:

  • 你有一个围绕这些代码的 updatePanel 吗?这可能是部分更新,因此您看不到更新后的控件。
  • 是的!就是这个问题,谢谢!

标签: asp.net asp.net-ajax ajaxcontroltoolkit


【解决方案1】:

问题在于模型弹出窗口中的 GridView 位于 UpdatePanel 内(感谢 nunespascal 指出这一点)。

为了解决这个问题,我添加了以下代码:

Protected Sub AddressGridView_RowDataBound(...) Handles AddressGridView.RowDataBound
    Dim AddressNameLinkButton As LinkButton = e.Row.FindControl("AddressNameLinkButton")
    ScriptManager.GetCurrent(Page).RegisterPostBackControl(AddressNameLinkButton)
End Sub

现在,当我按下 GridView 中的一个链接按钮时,模式弹出窗口将关闭并填充地址表单

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多