Passing Control's Value to Modal Popup

Posted by Sherwin Valdez on Stack Overflow See other posts from Stack Overflow or by Sherwin Valdez
Published on 2010-04-10T06:33:43Z Indexed on 2010/04/10 6:43 UTC
Read the original article Hit count: 450

Filed under:
|
|
|

Hello,

Just would like know how to pass textbox value to a modal popup after clicking a button using ModalPopUpExtender in ASP.NET, I've tried these codes but seems that I have no luck :(

 <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(); 

    }

I wonder what I miss out :(, Thanks and I hope someone could help me :)

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-ajax