【问题标题】:Introducing blank spaces and line breaks into title string?在标题字符串中引入空格和换行符?
【发布时间】:2013-01-31 14:44:34
【问题描述】:

如何修改以下代码以将 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>

输出如下:

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

【问题讨论】:

    标签: html razor newline spaces


    【解决方案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." 
            }
        );
    }
    

    【讨论】:

    • 你的意思是:@Html.Raw(Html.Encode(Model.MultiLineText).Html.RenderAction("GenericPopupPartial",...... ......?
    • 很抱歉没有仔细阅读您的评论,然后回复 no 只需添加 .RenderAction
    • 你可能甚至不需要它,我还没有测试过,只是把代码放在你的函数之前,它应该可以工作..
    • 我可能在某处遗漏了一个括号,但你明白了
    【解决方案2】:

    试试\n:

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

    【讨论】:

      猜你喜欢
      • 2015-08-03
      • 2019-11-01
      • 2018-05-24
      • 1970-01-01
      • 2013-09-11
      • 1970-01-01
      • 2011-01-17
      • 2012-03-18
      • 1970-01-01
      相关资源
      最近更新 更多