如何使用c#.net在消息文本中应用前置颜色和加粗

本文关键字:颜色 应用 何使用 net 文本 消息 | 更新日期: 2023-09-27 18:18:48

在保存值后显示一个确认框

showalert("Quote has been saved successfully. Your Submission Number is:" + SaveValue );

现在我已经显示了保存值粗体,下划线和一些前置色,如何应用(使用任何格式和HTML样式也)

如何使用c#.net在消息文本中应用前置颜色和加粗

您可以创建自己的javascript弹出式警报。

    function ShowAlert(message) {
      $('#popup').fadeIn(500);
      $('#popupmessage').html(message);
    };

你的html可以是这样的

    <div id="popup" class="window">
  <p id="popupmessage"></p>
</div>

后面的代码可以是

    ScriptManager.RegisterStartupScript(this, this.GetType(),"AlertScript","ShowAlert('Quote has been saved successfully. Your Submission Number is:<span style='text-decoration:underline;'>" + SaveValue + "</span>);"), true);

这样你就可以显示一个弹出式消息,并根据你的需要设置样式。

我不知道如何按照你的方式改变样式,但这里有另一种选择(它是用中文写的,但代码不是):

function ShowAlert(message) {    
   $('#popup').fadeIn(500);
var newmessage = "<span style='color:red;font-weight:bold;text-decoration:underline'>" + message + "</span>";
$('#popupmessage').html(newmessage); 
    };