Showing posts with label jQuery UI. Show all posts
Showing posts with label jQuery UI. Show all posts

Friday, November 2, 2012

jQuery UI Dialog with ASP.NET button postback issue


Issue:
When we use Asp.Net buttons in a panel, which is displayed as a Dialog using jQuery UI, the
post back events of the buttons do not fire.

Cause:
The cause of the issue it that, jQuery pulls the controls which are used in the dialog out of the form control, hence the post back events of these controls will not fire.

Resolution:
The solution for this issue is to add the controls back to the form, this can be done by adding the following line of code after the dialog script.

var promptDlg = $('#plnConfirm').dialog({ modal: true });
promptDlg.parent().appendTo(jQuery("form:first"));

Full Example
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>jQuery Dialog</title>
    <script type="text/javascript"
      src="javascript/jquery-1.7.2.js"></script>
    <script type="text/javascript"
      src="JavaScript/jquery-ui-1.8.21.custom.min.js"></script>
    <link
      type="text/css"
      href="styles/smoothness/jquery-ui-1.8.21.custom.css"
      rel="Stylesheet" />
    <script language="JavaScript"
      type="text/javascript">
        $(document).ready(function() {
           var promptDlg = $('#plnConfirm').dialog({ modal: true });
           promptDlg.parent().appendTo(jQuery("form:first"));
        });
    </script>
<
body id="bodyimg" onload="javascript:setSegOfferOptions();">
    <form id="form1" runat="server">
      <
asp:Panel
            ID="plnConfirm"
            style="border:0 double #000000;">
      <br />
      <asp:Label 
            ID="lblConfirm"
            runat="server"
            ForeColor="Maroon">Do you wish to                       
            continue?</asp:Label><br />
      <asp:Button
            ID="cmdYes"
            runat="server"
            Text="Yes"
            onclick="cmdYes_Click" />  
      <asp:Button
            ID="cmdNo"
            runat="server"
            Text="No"
            onclick="cmdNo_Click" />
      </asp:Panel>   
      </form>
</body>
</html>

Thursday, July 19, 2012

Asp.Net jQuery UI Tab Adding Images


In this post Asp.Net jQuery UI Tab Adding Images we shall on how to add images to the tab headers.

Images can be added to tab headers by adding appropriate tags to the
tags which are used to create the tab structure. Here is an example.





Add a DIV tag divImageTab to a page, and add the below jQuery script. Change the references of the jQuery library files to map to your local path. 

<html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
    <
title>jQuery UI Tabs</title>
    <link type="text/css"
href="css/smoothness/jquery-ui-1.8.21.custom.css"
rel="Stylesheet" />
    <script
type="text/javascript"
src="JavaScript/jquery-1.7.2.js"></script>
    <script
type="text/javascript"
src="JavaScript/jquery-ui-1.8.21.custom.min.js"></script>
    <link
type="text/css"
href="Stylesheet.css" // Add your own .css file (Optional)
rel="Stylesheet" />
    <script type="text/javascript">
$(document).ready(function() {
            // Icon Tab
      $("#divImageTab").tabs({ collapsible: true });
});
    </script>
</head>
<body>
    <form id="frmAccordion" runat="server">
        <table>
            <tr valign="top">
                <td>Icon Tab: </td>
                <td>
                    <div id="divIconTab">
                          <ul>
                                <li><a href="#tab4"><img src="images/Home.JPG" border="0"/>Tab-1</a></li>
                                <li><a href="#tab5"><img src="images/Security.JPG" border="0"/>Tab-2</a></li>
                                <li><a href="#tab6"><img src="images/Users.JPG" border="0"/>Tab-3</a></li>
                          </ul>
                          <div id="tab4">
                                Tab-1 Content goes here.
                          </div>
                          <div id="tab5">
                                Tab-2 Content goes here.
                          </div>
                          <div id="tab6">
                                Tab-3 Content goes here.
                          </div>
                    </div>
                </td>               
      </tr>
  </table>
    </form>
</body>
</html>

Asp.Net jQuery UI Tab Adding Icons



In this post Asp.Net jQuery UI Tab Adding Icons we shall on how to add icons to the tab headers.

Icons can be added to tab headers by adding appropriate icons classes to the

tags which are used to create the tab structure. Here is an example.




Add a DIV tag divIconTab to a page, and add the below jQuery script. Change the references of the jQuery library files to map to your local path. 

<html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
    <
title>jQuery UI Tabs</title>
    <link type="text/css"
href="css/smoothness/jquery-ui-1.8.21.custom.css"
rel="Stylesheet" />
    <script
type="text/javascript"
src="JavaScript/jquery-1.7.2.js"></script>
    <script
type="text/javascript"
src="JavaScript/jquery-ui-1.8.21.custom.min.js"></script>
    <link
type="text/css"
href="Stylesheet.css" // Add your own .css file (Optional)
rel="Stylesheet" />
    <script type="text/javascript">
$(document).ready(function() {
            // Icon Tab
      $("#divIconTab").tabs({ collapsible: true });
});
    </script>
</head>
<body>
    <form id="frmAccordion" runat="server">
        <table>
            <tr valign="top">
                <td>Icon Tab: </td>
                <td>
                    <div id="divIconTab">
                          <ul>
                                <li><a href="#tab4"><img class="ui-icon ui-icon-document" border="0"/>Tab-1</a></li>
                                <li><a href="#tab5"><img class="ui-icon ui-icon-comment" border="0"/>Tab-2</a></li>
                                <li><a href="#tab6"><img class="ui-icon ui-icon-locked" border="0"/>Tab-3</a></li>
                          </ul>
                          <div id="tab4">
                                Tab-1 Content goes here.
                          </div>
                          <div id="tab5">
                                Tab-2 Content goes here.
                          </div>
                          <div id="tab6">
                                Tab-3 Content goes here.
                          </div>
                    </div>
                </td>               
      </tr>
  </table>
    </form>
</body>
</html>