如何显示和使用C#中的MVC 3的Razor视图引擎隐藏股利? [英] How to Show and Hide Div using C# in MVC 3 Razor View Engine?

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

问题描述

我必须写C#代码的显示和隐藏的div在MVC3基于C#中。如何切换情况下的各种控件能不能做到不使用JQuery显示或隐藏..但在全服务器端..?

I have to write C# code for showing and hiding div in MVC3 for various controls based on switch case in C# .How can it be done without using JQuery Show or hide.. but in fully server side..?

推荐答案

直接添加您的switch语句到您的.cshtml文件。它都将在这一点上服务器端

Add your switch statement directly into your .cshtml file. It will all be server-side at that point.

控制器:

public ActionResult Page()
{
    string data = "value1";
    return View(data);
}



CSHTML:

CSHTML:

@model string; // this should be the Type your controller passes

<div>some html content</div>
@switch(Model) // Model is how you access your passed data
{
    case "value1":
        <div>...</div>
    break;
    case "value2":
        <div>...</div>
    break;
}
<div>more html content</div>

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆