I have to write C# code for showing or hiding div in MVC3 for various controls based on switch case.How can it be done without using JQuery show or hide function? I want it fully server-side in the class or controller file? inline C# in cshtml page also not preferred?
-
1Your cshtml can only dynamically control content if you "inline" code to determine what it displays. That's... just how it works. Why would you want to avoid that? You don't necessarily need the entire switch statement in your cshtml file though, you could set various properties in the ViewBag or ViewModel to determine what elements to display.Snixtor– Snixtor2013-03-07 10:15:47 +00:00Commented Mar 7, 2013 at 10:15
-
I don't see why you'd want to keep this code out of the cshtml page when a div is part of the view but...your call. You could fire a different view in the controller but this would be equally horrible from a design point of view.Robbie Dee– Robbie Dee2013-03-07 10:18:53 +00:00Commented Mar 7, 2013 at 10:18
-
possible duplicate of How to Show and Hide Div using C# in MVC 3 Razor View Engine?Michael Edenfield– Michael Edenfield2013-03-11 16:53:57 +00:00Commented Mar 11, 2013 at 16:53
Add a comment
|