Some small problems with ActionLink

Source: Internet
Author: User
Tags actionlink

Recently encountered a problem for the group of friends to solve the problem

Because I've never really met him before.

I hereby record

The cause is that the group of friends want to use htmlhelper to achieve such an effect

<href= "I am the link"  class= "I am the style"  data-toggle= "I am a custom attribute "> I am the link name </a>

Our traditional way of writing is this.

@Html. ActionLink (" I am the link name "" i am the link """new {@ class=" I am a style ", data-toggle=" I am a custom attribute "})

You'll find out when you try, and you'll get an error.

What's wrong with the newspaper?

Here are two key solutions

First of all, the "-" is replaced by an underscore.

@Html. ActionLink (" I am the link name "" i am the link """new {@ class=" I am a style ", data_toggle=" I am a custom attribute "})

Well, that will do what we expected.

The second way

@Html. ActionLink (" I am the link name "" i am the link """ "new dictionary<stringobject"class"" I am the style " " "data-toggle " " I am a custom attribute " }})

Well, these are the two ways we do it.

If you have other ways, welcome to add

Laughed at

Some small problems with ActionLink

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.