本文介绍了如何显示和使用C#中的MVC 2的aspx隐藏股利的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个新手做MVC和中间有人得到了stucked指导我。

I am a newbie in doing MVC and got stucked in middle someone guide me.

我想基于控制器动作隐藏 DIV 在视图中。

I want to hide div in view based on controller action.

查看code:

<div id="mudetails" runat="server" style="width: 99%; padding-top: 4%">
</div>

这是里面的内容我父母的div是present。

this is my parent div inside content is present.

控制器code。

public ActionResult Index()
        {  
            // div "mudetails" should not apper
            return View();
        }

 public ActionResult Index(string textbox)
        {
               // div "mudetails" should apper

        }

在页面加载的 DIV 不应冲击片雷管,但是当的ActionResult指数(字符串文本)动作triggerd的 DIV 应该出现。我尝试,但没能找到正确的解决办法。

In pageload the div should not apper but when ActionResult Index(string textbox) action is triggerd the div should appear.. I tried but not able to find correct solution.

推荐答案

您需要返回模型中的东西来表示它是否应该显示。在最简单的:

You need to return something in your model to indicate whether or not it should display. At its simplest:

    public ActionResult Index()
    {  
        // div "mudetails" should not apper
        return View(false);
    }

    public ActionResult Index(string textbox)
    {
       // div "mudetails" should apper
       return View(true);
    }

,然后在您的视图:

and then in your view:

    @Model bool

    @if (model) {
        <div id="mudetails" runat="server" style="width: 99%; padding-top: 4%">
        </div>
    }

这篇关于如何显示和使用C#中的MVC 2的aspx隐藏股利的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 06:57