I'm using razor syntax and I want to check to see if certain ViewBag values are set before I spit out the html. If a value is set then I want to write it out. If not I want it to do nothing.
@if (ViewBag.UserExists != null)
{ Response.Write(String.Format("<h3>{0}</h3>", ViewBag.UserExists)); }
This doesn't appear to be working correctly. The code shows up on top of another h2 I have above the code above. I have two register controller methods. One is the get and the other accepts the post. If the user exists I am setting a ViewBag item that needs to be displayed to the user.
Thanks
" + ViewBag.UserExists + "
")` as I believe the above will not render as desired if `ViewBag.UserExists` contains any HTML. – dav_i May 09 '13 at 08:35