Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial view html code is not rendered

Can anyone tell why the hidden value html is not rendered ? The debugger steps 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!

like image 381
mishap Avatar asked Dec 11 '25 22:12

mishap


1 Answers

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:

  1. 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.

  2. The hidden is not rendered => you have a bigger problem with some other part of your code that you haven't shown

  3. 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.

like image 128
Darin Dimitrov Avatar answered Dec 14 '25 20:12

Darin Dimitrov