Comments (1)
Hola Jess,
Va por muy buen camino tu sugerencia, la verdad es que de la manera que
está ahora no es muy elegante...
Pensaré en cambiarlo, gracias!!
iván
2012/1/11 jesusgarza <
[email protected]
Ivn,
Estoy comenzando a usar tu proyecto Invoicing-App y me est ayudando
mucho. Aprovecho para hacerte una sugerencia para Menu.cshtml: condicionar
la clase active usando un helper. Para eso se puede sacar cul es el
controlador y accin actual y pasarlo como parmetro:Definir al inicio de Menu.cshtml una variable con el controlador-accin
actual:@{ string currentControllerAction = ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString() + "/" + ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(); }Y en el men, condicionar la clase usando el helper:
<li class="@iloire_Facturacion.Helpers.MenuHelper.GetCssClassForMenu( currentControllerAction, "Invoice/Index")"> @Html.ActionLink("Invoices", "Index", "Invoice", new { proposal = false }, null) </li>El helper sera algo sencillo:
public static class MenuHelper { public const string ACTIVE_MENU_CSS_CLASS = "active"; public const string INACTIVE_MENU_CSS_CLASS = "inactive"; public static string GetCssClassForMenu(string currentControllerAction, string menuControllerAction) { if (currentControllerAction == menuControllerAction) return ACTIVE_MENU_CSS_CLASS; else return INACTIVE_MENU_CSS_CLASS; } }Referencias:
http://blog.janjonas.net/2011-02-15/aspnet-mvc_3-get-controller-action-razor-view
http://www.arrangeactassert.com/asp-net-mvc-view-best-practices-keep-logic-out-of-your-views/
Reply to this email directly or view it on GitHub:
#3
Ivan Loire - www.iloire.com
Desarrollo y formacin .NET (MCT)
(+34) 654 249068 - [email protected]
from asp.net-mvc-example-invoicing-app.
Related Issues (19)
- Build errors HOT 3
- issues while running the code HOT 1
- Unable to download the zip file HOT 1
- How to include the Database for this app? HOT 3
- Requesting for the database
- About Concurrency when create invoice
- Upgrade to MVC 5 HOT 1
- failed to compile in VS2015 HOT 2
- Failed to find or load the registered .NET Framework Data Provider HOT 2
- am unable to login. HOT 1
- Can you migrate this application?
- Problem with Pop-Up
- iloire_Facturacion.dll file is not founded
- linea de más HOT 1
- SecurityException HOT 1
- cant login during test HOT 3
- how do you change the currency HOT 1
- jQuery is not reusable. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asp.net-mvc-example-invoicing-app.