I have a simple callout partial included in this way I would like to implement or very close to it.
<partial name="_Callout" model='"Aviso:Todos..."' />
In the partial view I have this simple code (will make more complex later)
<div ><strong>Aviso</strong>Todos...</div>
I thought in the partial I will split the string and place the s[0] into the strong and s[1] into the div.
There has to be a simple way to pass a string, can probably do a new string[] {"",""} but not sure this is the correct method of passing data into a partial view.
CodePudding user response:
If you pass a string to partial view,and you split the data with ":",here is a demo to place the s[0] into the strong and s1 into the div:
<partial name="_Callout" model='"Aviso:Todos...:B:b:C:c"' />
partial view:
@model string
@{
string[] ls = Model.Split(":");
}
@for (var i = 0; i < ls.Length; i=i 2)
{
<div >
<strong>@ls[i]</strong>
@if (i 1 < ls.Length)
{
@ls[i 1]
}
</div>
}
result: