Common practice for dynamically changing css in MVC (4)

what am I used to so far when I need to dynamically set the style of html elements (using web forms), I installed hidden input data, passed data from the code behind and used jQuery to manipulate some elements.

therefore c# request> passes data to the hidden field html> jQuery read and execute.

  chosenHtmlElm.css({ 'background-image': 'url(images/RegF.png)' }, { 'visibility': 'visible' }); 

Is there a simple and elegant solution, or should I stick to my old school technique?

  web page with content items [type1] [default] [type2] [default] [] [] [] [] [] [] 

this may lead to an article / category on the website ...

therefore type1 has a left corner image, type 2 has a right angle image by default, has no

I am thinking of logic to give everyone a Content item category identifier, and then I could build some logic to control it, reorder, change icon ...

+7
jquery c # css asp.net-mvc-4
source share
1 answer

I think of MVC UI in three parts

  • Functionality through routing; various user interface pages for editing, list, etc.
  • Data provided through the model: some user interface states can be provided through the model and update the style using the model.
  • There is user interface logic that needs its own source to respond to user needs.

The final element includes AJAX updates: state selection (for example, rules based on an updated user interface drop-down list), GeoIP, and CSS changes that may be required. I use a separate controller for AJAX related to the user interface for a specific route. You can use the same controller, but I like to share the logic

0
source share

All Articles