zoukankan      html  css  js  c++  java
  • Three steps to use jQuery UI in ASP.NET MVC 5

    Many developers struggle to work with jQuery UI in an ASP.NET MVC application. In this post, I will show you three steps required to start working withjQuery UI in an ASP.NET MVC application. At the end of the post we will take a look at working with the autocomplete widget.
    The following three steps will let you work with jQuery UI in an ASP.NET MVC application:
    Step 1: Add the jQuery UI Reference
    Add the jQuery UI reference into the project using the NuGet manager. Once this is done, you should find the reference added in the Content folder and the Scripts folder.

    jqueryui1

    Step 2: Bundle the required files
    Open the BundleConfig.cs file. In this file add two entries, one for the jQuery UI scripts and other for jQuery UI CSS.
    Add the script entry as follows:

    Next add the CSS files for jQueryUI widgets.  CSS for all the widgets can be bundled like this:

    For the purpose of this example, let’s say you are only working with the autocomplete widget. In this case, you would only bundle the core.css andautocomplete.css as shown below:

    Step 3: Refer to the Bundles
    Once the bundles for jQuery UI have been created, you need to add them to the layout file. That can be done as follows:

    By default you will find the jQuery bundle at the end of the layout file. To work with jQuery UI widgets, you should move the jQuery bundle to the top of the file and also include the bundles for jQuery UI CSS and Scripts.
    You have now completed the three steps necessary to work with jQueryUI in an ASP.NET MVC application.
    Use jQueryUI Widgets 
    Now let’s look at the autocomplete widget in action.  I have created a controller for returning JSON data as follows:

    We will now bind the returned JSON from the GetMP() action to the autocomplete widget. On the razor view, you can create an autocomplete widget like this:

    Make sure the view is using the layout file in which you added the reference of the bundles.
    Summary 
    We’ve seen in this post that working with jQuery UI widgets is as simple as following three simple steps:

    1. Add the  jQuery UI reference
    2. Bundle the required files
    3. Refer to the bundles

    The autocomplete widget is also a helpful tool when working with jQuery UI bundles.
    I hope this post was useful. Happy coding.

  • 相关阅读:
    Android studio 使用flutter插件 运行第一个flutter项目 报错 Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
    Android 使用GPS获取到经纬度后 无法在Android8.0上使用Geocoder类获取位置信息
    Android 利用 gson 将 json 转成 对象object 集合list
    Android 6.0 7.0 8.0 一个简单的app内更新版本-okgo app版本更新
    iview组件 eslint校验出错 Parsing error: x-invalid-end-tag
    新建 Vue项目 使用iView报错解决
    Typora 自定义主题 修改左右间距
    Vue 嵌套数组 数组更新视图不更新
    如何在手机设备上实时调试
    通过ReRes让chrome拥有路径映射的autoResponse功能。
  • 原文地址:https://www.cnblogs.com/two/p/5255123.html
Copyright © 2011-2022 走看看