views:

99

answers:

1

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 :)

+1  A: 

use

value = document.getElementById('<%=TextBox1.ClientID %>').value;

instead of

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

alejandrobog
still doesn't work :(
Sherwin Valdez