【问题标题】:set value to master page controls inside content page in asp .net mvc view在 asp .net mvc 视图中为内容页面内的母版页控件设置值
【发布时间】:2016-05-09 15:29:26
【问题描述】:

我在内容页面中使用此代码来更改母版页的标签值。但这不起作用。我在 MVC 2 aspx 视图中执行此操作。

<%
        Label lbl = this.Master.FindControl("cov_year") as Label;
        lbl.Text = "Show val";

     %>

【问题讨论】:

  • 这是网络表单代码,不是 MVC

标签: asp.net-mvc master-pages


【解决方案1】:

实际上这是 webform 代码,所以它在 MVC 视图中不起作用。所以,我使用 jquery 来查找和设置值。

<script>
   var txt = "<%= titleformat%>";
   $("#cov_year").text(txt);
</script>

【讨论】:

    猜你喜欢
    • 2014-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 2010-11-07
    • 2017-12-13
    • 1970-01-01
    相关资源
    最近更新 更多