Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to block the background with my jquery modal dialog until the user closes the window. Any idea on how to achieve this?

By "blocking the background" I mean disabling the other elements on the page (i.e. making other elements unclickable).

Is there any errors on my coding????

What I have tried:

JavaScript
<script type="text/javascript">
        $( function () {
            $("[id*=btnadd]").live("click", function () {        
                $("#modal_dialog").dialog({
                    title: "Manage Branch",
                    autoopen: false,
                    width: 500,                 
                    buttons: {
                        ADD: function () {
                            var textvalue = $("#<%=TextBox2.ClientID%>").val();
                            $('#<%= hndtxt.ClientID %>').val(textvalue);
                            $("[id*=add]").click();
                        },
                        Close: function () {
                            $(this).dialog('close');
                        }
                    }
                });
            });
        } );
    </script>

<input type="button" id="btnadd" value="Add Branch" name="btnadd" style="float: right" />

 <div id="modal_dialog">
           <div class="tab_container">
                <div id="tab2" class="tab_content">
                    <table cellspacing="0">
                        <tbody>
                            <tr>
                                <td>
              
                                                                          
                                     Branch:
                                        <asp:TextBox ID="TextBox2" runat="server" Style="margin-left: 97px">
                                         <asp:label id="lbl_status" runat="server"  cssclass="red" text="">
                                        
                                     <br>
                                        <br>
                                                  </td>
                            </tr>
                                                                  
                        </tbody>
                   
                    </table>
                         
                </div>
                <!-- end of #tab1 -->
            </div>
            <!-- ID -->     

                     
        </div>
Posted
Updated 25-Oct-16 0:51am
Comments
Suvendu Shekhar Giri 20-Oct-16 3:27am    
"Is there any errors on my coding????"

Are you getting any?

Hello ,
You have to use modal option to get required out put .
Try this
<script type="text/javascript">
        $( function () {
            $("[id*=btnadd]").live("click", function () {        
                $("#modal_dialog").dialog({
                    title: "Manage Branch",
                    autoopen: false,
                    modal: true,
                    width: 500,                 
                    buttons: {
                        ADD: function () {
                            var textvalue = $("#<%=TextBox2.ClientID%>").val();
                            $('#<%= hndtxt.ClientID %>').val(textvalue);
                            $("[id*=add]").click();
                        },
                        Close: function () {
                            $(this).dialog('close');
                        }
                    }
                });
            });
        } );
    </script>

Thanks

Documentation : Here
 
Share this answer
 
Comments
Karthik_Mahalingam 20-Oct-16 4:20am    
5
Aashish68 20-Oct-16 4:41am    
when i give modal:true it works but the ADD button is not firing.without giving modal:true ADD button works well
why it is not firing when i give modal:true?
Animesh Datta 20-Oct-16 6:26am    
Thank You !
Aashish68 20-Oct-16 4:35am    
when i give modal:true it works but the ADD button is not firing.without giving modal:true ADD button works well
why it is not firing when i give modal:true?
Karthik_Mahalingam 20-Oct-16 5:05am    
i have tested your code with modal:true? it works fine.
you might be missing something.
When using modal:true we have to use ajax call for firing the button in jquery modal popup or else we can use another method.


JavaScript
<pre lang="Javascript"><pre lang="Javascript"><script type="text/javascript">
        $(function () {
            $("#modal_dialog").dialog({
                title: "Manage Branch",
                autoOpen: false,
                width: 400,
                open: function () {
                    $('#disableBackGround').attr('style', 'display:block');
                },
                buttons: {
                    ADD: function () {
                        var textvalue = $("#<%=TextBox2.ClientID%>").val();
                        $('#<%= hndtxt.ClientID %>').val(textvalue);
                        $('#<%=add.ClientID %>').click();
                    },
                    Close: function () {
                        $('#disableBackGround').attr('style', 'display:none');
                        $(this).dialog('close');
                    }
                }
            });
            $("[id*=btnadd]").live("click", function () {
                $("#modal_dialog").dialog('open');
                return false;
            });
        });
    </script>





<input type="button" id="btnadd" value="Add Branch" name="btnadd" style="float: right" />
<asp:button id="add" runat="server" text="ADD" style="display: none" onclick="btninsert_Click">



 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900