I need to add class attribute to the body tag from a view file (.aspx), but the tag is in the master file. How can I access the body tag from a view?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your view output you could just add a jQuery client script to do it which will run once your page is pieced together:
Another method would be to store the class data in your controller like:
Then in your
MasterPageview you could check for the existance of this and add it if it exists:Only the controller actions that required the class to be attached to the body would actually need to store the class in the
ViewDataevery other action could just ignore it.