asp.net mvc - why DropDown() helper method does not display the dropdown when it was used in a C# block? -


i have following view code generate drop down list control.when code written in c# block not display drop down

here code

@{     viewbag.title = "index";     html.dropdownlist("id", model.catcoll);     } 

but when write outside of c# block displays.. why happens , how fix this?

whatever inside @{ } should c# code, whatever outside of it, should asp.net code.

if want combine 2 in order display c# values inside html, can use following style: @someproperty

example:

<h1>@viewbag.title</h1> 

fix problem, put dropdownlist outside:

@html.dropdownlist("id", model.catcoll); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -