• Html.ActionLink Url.Action的用法


    最近在公司做一个股票频道的项目,web层的开发需要用mvc开发,以前没用过,这段时间在慢慢的琢磨.

    这里是对Html.ActionLink Url.Action的用法的一些体会

    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Shumi.Stocks.CompanyInfo>" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>公司概况</title>
    </head>
    <body>

      <% Html.BeginForm("CompanyInfo", "Company", FormMethod.Get, new { id = "form1" }); %>
        <div>
        <a href="<%=Url.Action("CompanyInfo", "Company", new { stockId = "11111" })%>" >       查询</a>
        <div>
            <input name="stockId" type="text" id="stockId" class="txt" />
            <input type="submit" name="btnQuery" value="查询" id="btnQuery" />
        </div>
         <%= Html.ActionLink("主营业务", "CompanyInfo", "Company", new { stockId = "22222" }, null)%>

       <% Html.EndForm(); %>
    </body>
    </html>

    controller中的action特性默认是HttpGet

    要注意的是action中的方法参数必须和Url.Action,Html.ActionLink传入的id一致

       /// <summary>
            /// 公司概况
            /// </summary>
            /// <returns></returns>
            public ActionResult CompanyInfo(string stockId)
            {

                string id = stockId;

               // stockId = stockId ?? 111;

                //  CompanyInfo cinfo = CompanyInfoClient.Instance.GetCompanyInfo("8BBB337A-AB56-409F-A454-3F735AEA14C2");
                //  ViewData["cinfo"] = cinfo;T
                return View();
            }

  • 相关阅读:
    TyvjP2018 「Nescafé26」小猫爬山
    简化版桶排序
    getchar吸收回车
    fprintf与fscanf
    c语言命令行参数
    bit、byte、位、字节、汉字的关系
    C语言联合体
    结构体
    关于Integer的parseInt(String s, int radix)方法的使用
    java中nextLine()和next()的区别
  • 原文地址:https://www.cnblogs.com/mylife_001/p/1876659.html
Copyright © 2020-2023  润新知