2014-11-19 2 views
0

У меня есть частичный вид, который будет отображаться панель и некоторый текст, как показано ниже ..PartialView и секции

<div class="panel panel-warning customHidden" id="infobox"> 
<div class="panel-heading"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> information</div> 
<div class="panel-body well-sm"> 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
</div> 

Я хотел бы текст раздела этого быть переданы по мнению, потребляет частичное представление. как я могу передать текст и поддерживать html div вокруг текста?

ответ

0

Вы можете использовать (ViewBag) в самом частичный вид. Рассмотрим следующий фрагмент

@{ 
 
    ViewBag.Text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."; 
 
} 
 

 
<div class="panel panel-warning customHidden" id="infobox"> 
 
<div class="panel-heading"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> information</div> 
 
<div class="panel-body well-sm"> 
 
    @ViewBag.Text 
 
</div>

0

Использовать элемент ViewBag. Является динамическим объектом.

ViewBag.DivText = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem.." 

Тогда .. Вы можете использовать @ ViewBag.DivText на ваш взгляд:

<div class="panel panel-warning customHidden" id="infobox"> 
<div class="panel-heading"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> information</div> 
<div class="panel-body well-sm">@ViewBag.DivText</div> 
+0

Вот один из способов сделать это спасибо, это можно сделать непосредственно в представлениях вместо контроллеров? – Zoinky

+0

Да, вы можете сделать это на виду: '@ { ViewBag.DivText =" Lorem Ipsum - просто фиктивный текст печатной и верстки. Lorem .. "; } ' –