【问题标题】:Pass a value from DB to a URL as the parameter将值从 DB 传递到 URL 作为参数
【发布时间】:2012-11-19 10:53:23
【问题描述】:

我在下面的 URL 中传递了 2 个参数。中期和实践。 MID 是用户的 id,当用户登录到站点时将被传递。现在要获得“Prac”,我需要将此 MID 传递到我的数据库中的表并获取值。请告诉我我应该如何去做。

    a href="@Url.Content("https://something/someserver?%2fWEBSITE%2fProj_FinancialPerf&
    MID="+ Convert.ToInt32(System.Web.HttpContext.Current.User.Identity.Name.Replace("***\\", ""))+"&Prac=SOMETHING")"  id="LinkButton7" name="LinkButton7"  new { target = "_blank" }) value="@Resource.Get("ManagerReportsPageInputScreen13_LinkButton7")">
@Resource.Get("ManagerReportsPageInputScreen13_LinkButton7")</a> 

提前致谢

【问题讨论】:

    标签: javascript jquery asp.net asp.net-mvc-3 razor


    【解决方案1】:

    您可以将 Prac 设置为模型中的变量(在控制器中执行此操作),然后像 @Model.Prac 一样使用该变量

    Public ActionResult Index(){
        var pageModel = new PageModel;
        pageModel.Prac = "WHATEVERPRACIS"
        return View(model);
    }
    
    @Html.ActionLink("button text", "Index" , new { Prac = Model.Prac, Mid = Model.Mid, etc = etc})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-19
      • 1970-01-01
      • 2010-12-18
      • 2015-08-20
      相关资源
      最近更新 更多