【问题标题】:MVC buttons linking to image链接到图像的 MVC 按钮
【发布时间】:2014-07-18 06:16:46
【问题描述】:

我是 C# 新手,所以我在连接到控制器的图像链接时遇到问题。

我创建了这个将用户路由到控制器的链接。现在它是一个提交按钮,上面写着“立即注册”,但我不想这样做,而是使用图像。我只是为一个简单的按钮创建链接没有问题,但不知道如何使用图像执行此操作。

这是我的代码

    @Html.SubmitButton("Sign Up Now!", OrdersController.AddSubscriptionRoute, new { pl=1, itemCode = Model.ItemCode, webId = Model.WebID, webCategoryId = Model.WebCategoryID, priceTypeId = Model.PriceTypeID }, null, ActionEmphasis.Callout)

我想使用图片

 <img src="/_resources/images/content/callout.jpg" style="float:right">

【问题讨论】:

    标签: c# button controller routes


    【解决方案1】:

    如果您想让表单发布到特定操作,您只需要以下内容:

    <form action="<%:Url.RouteUrl("Your Route Here");%>" method="post">
     <!-- Html Input elements -->
     <input type="image" src="/_resources/images/content/callout.jpg" style="float:right;" alt="Submit" />
    </form>
    

    如果您需要在表单上有多个按钮,请考虑这篇文章:

    http://blog.maartenballiauw.be/post/2009/11/26/Supporting-multiple-submit-buttons-on-an-ASPNET-MVC-view.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-27
      • 1970-01-01
      • 1970-01-01
      • 2014-01-04
      • 2015-11-13
      • 1970-01-01
      相关资源
      最近更新 更多