Partial view html code is not rendered
Can anyone tell why the hidden value html is not rendered ? The debugger 开发者_StackOverflowsteps into the conditional, but hidden field is not on the page.
<% if (ViewData[Constants.ViewDataKeyandValues.Page]!= null)
{%>
<input type="hidden" name="Language" value="English" />
<%} %>
The project is MVC 2. Thank you!
Here's what you may try: remove the if
condition and let the hidden field unconditional:
<input type="hidden" name="Language" value="English" />
Now there are 3 possibilities:
The hidden is rendered => you haven't set a value in
ViewData[Constants.ViewDataKeyandValues.Page]
inside your controller action. So set a value and you should be fine.The hidden is not rendered => you have a bigger problem with some other part of your code that you haven't shown
By rendered you mean be part of the HTML source when you view the page but this view was included as part of an AJAX request so the hidden field is correctly injected into the DOM, it's just that you don't see it in the source. Inspect your DOM tree with tools like FireBug and you're gonna see it.
精彩评论