Juice UI: ASP.Net Web Forms With jQuery UI

Introduction

Juice UI is an open-source ASP.NET Web Forms components for jQuery Widgets. We use all jQuery UI components like ASPX Server-side controls. Here we learn and use the Juice UI control in Aspx Web Forms. The Juice UI Control is also available for ASP.NET MVC Control as a helper method.

Description

The Juice UI requires .NET 4.0. Please ensure that the proper version of .NET is installed before attempting to integrate Juice UI Controls. The Juice UI can be installed using the NuGet Package Manager as in the following:

PM> Install-Package JuiceUI

Note: When using the Juice UI Control the TargetControl attribute is required to be set with the ASPX Control ID. Before using the Juice UI Control add a ScriptManager to the page.

All jQuery Widget and Juice UI Controls have the same attribue.

  1. Date Picker Control
    1. <asp:TextBox runat="server" ID="txtDate" />  
    2.   
    3. <Juice:datepicker  
    4.             runat="server"  
    5.             targetcontrolid="txtDate"  
    6.             mindate="-20"  
    7.             maxdate="+1M +10D" />  
    Note: the Juice UI DatePicker control supports all the attributes supported by jQuery UI DatePicker.

  2. Auto Complete Control
    1. <asp:TextBox runat="server" ID="txtLanguage" placeholder="Type Word" />  
    2.   
    3. <asp:TextBox runat="server" ID="txtLanguagerFromWebAPI" placeholder="Type Word" />  
    4.   
    5. <Juice:Autocomplete ID="_Autocomplete" runat="server" TargetControlID="txtLanguage" Source="ActionScript, AppleScript, Asp, BASIC, C, C++, Clojure, COBOL, ColdFusion, Erlang, Fortran, Groovy, Haskell, Java, JavaScript, Lisp, Perl, PHP, Python, Ruby, Scala, Scheme" />  
    6.   
    7. <juice:Autocomplete ID="_Autocomplete1" runat="server" TargetControlID="txtLanguagerFromWebAPI" SourceUrl="/API/Service/GetLanguage" />  
    Note: implementing an autocomplete control requires the source to bind the data as autocompleted. Here in this demo I have used both a static as well as a dynamic Ajax or Web API based source to bind with Juice UI AutoComplete.
  3. Dialog Control
    1. <div id="_Default" title="Basic dialog" runat="server"></div>  
    2.   
    3. <juice:Dialog ID="_Dialog" Height="300px" TargetControlID="_Default" runat="server" Buttons="{ Ok: function() { $(this).dialog('close');}}" AutoOpen="false" />  
    4.   
    5. <a href="#" id="lnkDialog">Click to Open Dialog</a>  
    Note: opening the dialog requires adding a JavaScript function to trigger the dialog to open.
    1. <script type="text/javascript">  
    2.         // Click Link to open Dialog  
    3.         $("#lnkDialog").click(function (e) {  
    4.             e.preventDefault();  
    5.             // Open the dialog   
    6.             $("#_Default").dialog("open");  
    7.         });  
    8. </script>  
  4. Slider Control
    1. <p>Single Slider</p>  
    2.    
    3. <div><asp:Literal runat="server" ID="currentValue" /></div>  
    4.   
    5.      <Juice:Slider ID="slider2" runat="server" Max="150" />  
    6.   
    7.       <p>Two Value Slider</p>  
    8.   
    9.       <div><span id="slider2Value"></span></div>  
    10.    
    11.       <juice:Slider ID="_Range" runat="server" Range="true" Min="0" Max="500" Values="75, 300" />  
  5. Menu Control
    1. <Juice:Menu ID="_Menu" runat="server">  
    2.          <juice:MenuItem ID="Menuitem1" runat="server">  
    3.              <Content><a href="#">Item 1</a></Content>  
    4.          </Juice:MenuItem>  
    5.          <juice:MenuItem ID="Menuitem2" runat="server">  
    6.              <Content><a href="#">Item 2</a></Content>  
    7.          </Juice:MenuItem>  
    8.          <juice:MenuItem ID="Menuitem3" runat="server">  
    9.              <Content><a href="#">Item 3</a></Content>  
    10.              <Items>  
    11.                  <Juice:MenuItem ID="Menuitem4" runat="server">  
    12.                      <Content><a href="#">Item 3-1</a></Content>  
    13.                  </juice:MenuItem>  
    14.                  <Juice:MenuItem ID="Menuitem5" runat="server">  
    15.                      <Content><a href="#">Item 3-2</a></Content>  
    16.                  </juice:MenuItem>  
    17.                  <Juice:MenuItem ID="Menuitem6" runat="server">  
    18.                      <Content><a href="#">Item 3-3</a></Content>  
    19.                  </juice:MenuItem>  
    20.                  <Juice:MenuItem ID="Menuitem7" runat="server">  
    21.                      <Content><a href="#">Item 3-4</a></Content>  
    22.                  </juice:MenuItem>  
    23.                  <Juice:MenuItem ID="Menuitem8" runat="server">  
    24.                      <Content><a href="#">Item 3-5</a></Content>  
    25.                  </juice:MenuItem>  
    26.              </Items>  
    27.          </Juice:MenuItem>  
    28.          <juice:MenuItem ID="Menuitem9" runat="server">  
    29.              <Content><a href="#">Item 4</a></Content>  
    30.          </Juice:MenuItem>  
    31.          <juice:MenuItem ID="Menuitem10" runat="server">  
    32.              <Content><a href="#">Item 5</a></Content>  
    33.          </Juice:MenuItem>  
    34.   
    35. </juice:Menu>  
    Note: Here in this menu control I have provided a nested menu example also.
  6. Tab Control
    1. <Juice:Tabs ID="_Tabs" runat="server" PanelTemplate="<div>!</div>" AutoPostBack="true">  
    2.      <juice:TabPage Title="Tab 1" ID="Tab1">  
    3.          <TabContent>  
    4.              <p>This should display on tab 1.</p>  
    5.              <asp:TextBox ID="_Textbox" runat="server" />  
    6.          </TabContent>  
    7.      </Juice:TabPage>  
    8.   
    9.      <juice:TabPage Title="Tab 2" ID="Tab2">  
    10.          <TabContent>  
    11.              <p>This should display on tab 2.</p>  
    12.          </TabContent>  
    13.      </Juice:TabPage>  
    14. </juice:Tabs>  
  7. Accordion Control
    1. <Juice:Accordion ID="_Accordion" runat="server">  
    2.     <juice:AccordionPanel Title="Panel 1">  
    3.         <PanelContent>  
    4.             Panel 1's content.  
    5.             <asp:TextBox runat="server" ID="dob1" ClientIDMode="Static" />  
    6.             <Juice:Datepicker ID="Datepicker1" runat="server" TargetControlID="dob1" />  
    7.          </PanelContent>  
    8.      </juice:AccordionPanel>  
    9.   
    10.      <Juice:AccordionPanel Title="Panel 2">  
    11.           <PanelContent>  
    12.              Panel 2's content.  
    13.           </PanelContent>  
    14.      </juice:AccordionPanel>  
    15. </Juice:Accordion>  
Reference
  1. Github: appendto/juiceui

Note: I have use the demo from the Juice UI Open-source GitHub Repository as above.

Conclusion

In this article we learned a new way to use jQuery UI Control using Server-side Control Juice UI Library. We have seen the most used Juice UI controls like Date Picker, Accordion, Auto complete and so on. I hope you enjoy this article.