【问题标题】:Passing Control's Value to Modal Popup将控件的值传递给模态弹出窗口
【发布时间】:2010-04-10 06:33:43
【问题描述】:

只是想知道如何在 ASP.NET 中使用 ModalPopUpExtender 单击按钮后将文本框值传递给模式弹出窗口,我已经尝试过这些代码,但似乎我没有运气:(

 <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.Attributes.Add("onclick", "showModalPopup(); return false;");
    }
</script>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick='showModalPopup(); return false;' />

    <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button1"
        PopupControlID="Panel1" CancelControlID="btnCancel" OkControlID="btnOkay" BackgroundCssClass="ModalPopupBG">
    </cc1:ModalPopupExtender>
    <asp:Panel ID="Panel1" Style="display: none" runat="server">
        <div class="HellowWorldPopup">
            <div class="PopupHeader" id="PopupHeader">
                Header</div>
            <div class="PopupBody">
                <asp:Label ID="Label1" runat="server"></asp:Label>
            </div>
            <div class="Controls">
                <input id="btnOkay" type="button" value="Done" />
                <input id="btnCancel" type="button" value="Cancel" />
            </div>
        </div>
    </asp:Panel>

javascript

 function showModalPopup() {
        //show the ModalPopupExtender
        var value;
        value = document.getElementById("TextBox1").value;
        $get("<%=Label1.ClientID %>").value = value;
        $find("<%=ModalPopupExtender1.ClientID %>").show(); 

    }

我想知道我错过了什么:(,谢谢,我希望有人可以帮助我:)

【问题讨论】:

    标签: c# .net asp.net asp.net-ajax


    【解决方案1】:

    使用

    value = document.getElementById('').value;

    而不是

    value = document.getElementById("TextBox1").value;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      相关资源
      最近更新 更多