MVC - RouteLink and Image

后端 未结 3 1199
别跟我提以往
别跟我提以往 2021-02-20 09:45

I\'d like this output:


    \"\"
    <         


        
3条回答
  •  我寻月下人不归
    2021-02-20 09:58

    The first parameter of the RouteLink method is for the link text. But unfortunately, it gets encoded automatically, so you cannot send <, > characters to it. (Well, you can. But they'd get encoded.)

    Take a look at this page.

    Route values are URL encoded automatically. For example, the string “Hello World!” is encoded to “Hello%20World!”.

    Rendering Image Links

    Unfortunately, you can’t use the Html.ActionLink() helper to render an image link. Because the Html.ActionLink() helper HTML encodes its link text automatically, you cannot pass an tag to this method and expect the tag to render as an image.

    Instead, you need to use the Url.Action() helper to generate the proper link. Here’s how you can generate a delete link with an image:

    ">
      Delete
    
    

提交回复
热议问题