Some advice for ASP.net Mvc and JQuery UI users

Source: Internet
Author: User
Tags aop jquery ui autocomplete

Happy Dragon Boat Festival, everybody.

I haven't written a blog for a long time. 1 months have been .... I'm sorry.

Today gives some advice and sharing experience to developers who use asp.net mvc.

First of all, if you're using asp.net mvc and you're using a JS library that's jquery, then be sure to skip using the jquery UI.

In my previous job, if I needed to write a Google search-like AutoComplete, it might involve JS writing, CSS styling, and how the background code generates JSON or XML passes to the AutoComplete control.

Now that you can use the jquery UI AutoComplete, your workload will be surprisingly low. See how I can achieve:

1. Add jquery UI js and CSS references.

2. Add a TextBox to the page and use the AutoComplete script on the textbox:

3. Add action and return JSON.

In the second step we see the TextBox with ID complete its source is the action:users under the controller. So next we're going to implement the users action:

We use ASP.net MVC's own JSON transformation to convert a string array to JSON and return it to the client's AutoComplete control.

Run the next look at the results:

Enter an "s" First:

When you set a breakpoint on the action, you can see that the AutoComplete control of the jquery UI has the S serialized to the server side, ASP.net mvc to the method users (string term) after it is deserialized.

Here we write an array and serialize the array into JSON and return to the client, the client result:

Just a few easy steps to get it done automatically.

The most exciting thing is that all of the styles are complete to generate the skin you need on the jquery UI Web site, then export, and replace the existing jquery ui css file just ok.

Second, I think it's worth using the jquery UI dialog controls and DatePicker controls.

Your DatePicker finish can be made into a generic control placed under the share folder.

The use of the dialog control allows you to change the additions and deletions to pop-up boxes to display, enhance the friendly type of the site. Here you need to combine the Ajax methods of jquery, such as load,get to load the view page, and then use the serialization method of jquery to post the data to the server side.

Specific examples I will try to write a few, today in a hurry not to write first.

The last part wants to share with you some advice from developers who use asp.net mvc:

A. Delete AccountController first, never use the user management controller, to achieve.

B. Use the IOC container. Only the good is no harm. such as Autofac,ninject. But the beginner programmer first notices the monomer mode and Factory mode of the IOC container, otherwise you will find your tragedy after the project is used. Learn more and understand more, otherwise, do not use in the project.

C. Try not to use viewdata this thing.

D. Remember to use the filter attribute to implement AOP programming, you don't have to write your AOP component yourself. For example Dynamic.proxy These all do not consider first, consider the global Filter firstly.

E. Customize your viewengine. You need to define your viewengine, otherwise you will find that many extensions are not achievable ....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.