简体   繁体   中英

ColorBox (jquery plug in) my textbox values are empty after postback

I'm having trouble getting the values from text box when using ColorBox http://colorpowered.com/colorbox/

I have a form that opens a ColorBox modal dialog.In the modal i have a asp.net textbox and a button when i click the button i'm getting the postback but the value of the textbox is always empty.

<script type="text/javascript">
        $(document).ready(function () {
            $(".example8").colorbox({ width: "50%", inline: true, href: "#inline_example1" });
        });
    </script>

....

<form id="form1" runat="server">
    <a href="content/ohoopee1.jpg" rel="example8" title="abc">Click here</a></p> <a class='example8'
        href="#">Inline HTML</a></p>
    <!-- This contains the hidden content for inline calls -->
    <div style='display: none'>
        <div id='inline_example1' style='padding: 10px; background: #fff;'>
            <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton><asp:TextBox
                ID="TextBox1" runat="server"></asp:TextBox>
        </div>
    </div>
    </form>

Any help will be appreciated. Thanks.

Try adding the following code to the method call:

$("#colorbox").appendTo('form'); 

So your code will look like this:

<script type="text/javascript">
    $(document).ready(function () {
        $(".example8").colorbox({ width: "50%", inline: true, href: "#inline_example1" });
        $("#colorbox").appendTo('form');
    });
</script>

At least that's what worked for me!
Hope this helps!

This problem occurs because the Colorbox's content is created outside form tag. To resolve the problem edit the colorbox.cs and edit the method that create the modal. If you prefer, you can download the file that I changed and fix the problem. http://www.coyote.inf.br/jquery.colorbox.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM