MVC application, dynamic creation of Radio list (RadioButtonList)

Source: Internet
Author: User

The Radio list is a number of options that allow the user to select one. MVC application Development, less. Here's a little function to practice.

This exercise, insus.net want to implement a date display format. In MVC, you need to create from model:



Then create an entity that will provide the data source for the radio list:

Open a previous practice, create a good view views\home\index.cshtml, add a div tag, so that radio dynamically add, can be loaded in this.

You can start writing jquery code below:



#1引用jQuery的js库.
#2获取单选列表的数据源.
#3循环产生单选项Radio.

In the view preview effect:

Now is the horizontal display option, if you want to achieve vertical display, you need to add a sentence in the jquery code in the # # section:

$ (' <br/> '). AppendTo ("#RadioDateFormat");


Details are as follows:

The run appears as follows:


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.