How to Show and Hide Div using C# in MVC 2 aspx

asp.net-mvc, c#

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>
    }

Problem

I am a newbie in doing MVC and got stucked in middle someone guide me. I want to hide `div` in view based on controller action. View code: ``` <div id="mudetails" runat="server" style="width: 99%; padding-top: 4%"> </div> ``` this is my parent div inside content is present. Controller code. ``` public ActionResult Index() { // div "mudetails" should not apper return View(); } public ActionResult Index(string textbox) { // div "mudetails" should apper } ``` 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.

Original source