开发者

Partial view html code is not rendered

开发者 https://www.devze.com 2023-03-18 14:46 出处:网络
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.

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:

  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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号