Link to home
Start Free TrialLog in
Avatar of Scarlett72
Scarlett72

asked on

jquery dialog form example and help

Hi, I am trying to put a asp.net form into a jquery popup dialog  box.
My script is in the head tag of a master page and my form is in a content page.  This is what I have so far, if I set the autoOpen: false the form pops up without the openme button click event first and the form won't submit, if I set it to open false the page refreshes but the dialog does not work.  Looking for help with the code and a better example of of a asp.net form inside a jquery dialog box?  Thanks!!!

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

<script>
 $(document).ready(function () {
        $("#dialog").dialog({ autoOpen: false });
 
        $("#btnOpenMe.ClientID").click(
            function () {
                $("#dialog").dialog('open');
                return false;
            }
        );
    });
</script>

 <div id="dialog">
       
    <table>
        <tr>
            <td colspan="2" style="text-align:center">
                Update Form
            </td>
        </tr>       
        <tr>
            <td>
                <asp:Label ID="lblUpdate" runat="server" Text="Update Reason:"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtUpdate" TextMode="MultiLine" Columns="30" Rows="5" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            
            <td>
                <asp:Button ID="btnSupmitUpdate" runat="server" Text="Button" OnClick="btnSupmitUpdate_Click" />
            </td>
        </tr>
    </table>
    </div>
     <asp:Button ID="btnOpenMe" runat="server" Text="Click Me to open Dialog box" />

Open in new window

Avatar of Gary
Gary
Flag of Ireland image

Nothing wrong with the code per se.
Do you have a link to a live page or can you post the full rendered HTML
My script is in the head tag of a master page and my form is in a content page.

Based on your comment, this line of code $("#btnOpenMe.ClientID").click is not going to work in your Master Page script. Try giving some class name say class="testButton" to the button and modify script like $('.testButton'),click

However, if you have both script and asp button in child content page only then you can also modify above script line to $('#' + '<%= btnOpenMe.ClientID %>').

Try this & lemme know if you have any issues.

Cheers,
Shah Md.
ASKER CERTIFIED SOLUTION
Avatar of PatelRitesh
PatelRitesh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial