在标题字符串中引入空格和换行符?

时间:2013-01-31 14:44:34

标签: html razor newline spaces

如何修改以下代码以将Title字符串值分成两行? 中心对齐似乎也不起作用。我错过了什么吗?

@{ 
    Html.RenderAction(
        "GenericPopupPartial", 
        "Shared", 
        new { 
            containerName = "registerSuccess",  
            BodyHtml = Model.MessageSent, 
            Title = "Thank you for registering!       Our representatives will  review your request and email you with access to our product section shortly." 
            }
        );
}

<a class="fbox1" id="registerSuccess-link" href="#registerSuccess" style="display: none; text-align:center;"></a>

输出如下:

  

感谢您的注册!我们的代表将审核您的请求   并通过电子邮件向您发送我们的产品部分。

2 个答案:

答案 0 :(得分:1)

尝试\n

Title = "Thank you for registering!\nOur representatives will  review your request and email you with access to our product section shortly."

答案 1 :(得分:1)

尝试

  @Html.Raw(Html.Encode(Model.MultiLineText)  

并在行之间包含\ n字符

以下内容将用新行替换'break'字符。也许试试吧。

@Html.Raw(Html.Encode(Model.MultiLineText).Replace("\n", "<br />")){"GenericPopupPartial", 
    "Shared", 
    new { 
        containerName = "registerSuccess",  
        BodyHtml = Model.MessageSent, 
        Title = "Thank you for registering! <br /> Our representatives will  review your request and email you with access to our product section shortly." 
        }
    );
}