惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
Schneier on Security
Schneier on Security
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
A
About on SuperTechFans
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
V2EX - 技术
V2EX - 技术
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
V
Visual Studio Blog
Martin Fowler
Martin Fowler
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
Scott Helme
Scott Helme
H
Heimdal Security Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Vulnerabilities – Threatpost
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Troy Hunt's Blog
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
Jina AI
Jina AI
S
Securelist
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
AWS News Blog
AWS News Blog
N
News and Events Feed by Topic
博客园 - 三生石上(FineUI控件)
量子位

博客园 - 赶路人之刚出发

集成WebSecurity的Authorize进行身份验证时,数据库连接报错问题 Automapper结合EF实现insert,update方法 MVC中使用RemoteAttribute异步远程验证 Html.RenderPartial WebMatrix.WebSecurity创建自定义用户属性 强类型view中List<Model〉问题 ViewBag任意属性的实现方法 params关键字 配置LINQ中的datacontext的log路径,以记录datacontext执行了的查询sql SortedList LINQ join/left join/cross join/group by/group join/sortedlist/cast Linq to objects示例 yield return 和 Func Lamda表达式 IDisposable 匿名类型与扩展方法 对象初始化器和集合初始化器 C#自动属性 .net random伪随机数
Html.ActionLink传递参数
赶路人之刚出发 · 2013-06-19 · via 博客园 - 赶路人之刚出发
  //
        // 摘要:
        //     返回包含指定操作的虚拟路径的定位点元素(a 元素)。
        //
        // 参数:
        //   htmlHelper:
        //     此方法扩展的 HTML 帮助器实例。
        //
        //   linkText:
        //     定位点元素的内部文本。
        //
        //   actionName:
        //     操作的名称。
        //
        //   routeValues:
        //     一个包含路由参数的对象。通过检查对象的属性,利用反射检索参数。该对象通常是使用对象初始值设定项语法创建的。
        //
        // 返回结果:
        //     一个定位点元素(a 元素)。
        //
        // 异常:
        //   System.ArgumentException:
        //     linkText 参数为 null 或为空。
        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues);

该方法会调用当前controller的名为actionname的action方法,同时传递routedValues为参数至该方法。

比如:

@Html.ActionLink("投资申请", "AddInvest", Model.Investors.FirstOrDefault())

对应Action定义如下,接受参数类型需与传递参数类型一致:

  public ActionResult AddInvest(InvestorInfo investor)

那如果只想传递一个简单类型参数,比如int,该怎么办呢?

Action定义如下:

 public ActionResult CSR2Detail(int contractID)

调用时应该这样:

 @Html.ActionLink("复核", "CSR2Detail", new { contractID = @myModel.ContractID })

因为第3个参数routedValues必须为一个object,执行时通过反射检索该对象中的属性来进行参数的映射,所以这里我们需要构造一个包含一个contractID属性的匿名类对象进行传递