Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 样式。添加会扭曲字符串,将空格替换为“%20“;_C#_Asp.net_Css - Fatal编程技术网

C# 样式。添加会扭曲字符串,将空格替换为“%20“;

C# 样式。添加会扭曲字符串,将空格替换为“%20“;,c#,asp.net,css,C#,Asp.net,Css,现在,在即时窗口中,我执行以下操作: string backgroundImage = "url(http://path/alert.png), linear-gradient(-45deg, #8c7814 0%, #a99118 100%)" panel.Style.Add("background-image", backgroundImage); 导致: panel.Style.Value 提供了什么?我建议您在css类中添加这些样式 "background-image:url(htt

现在,在即时窗口中,我执行以下操作:

string backgroundImage = "url(http://path/alert.png), linear-gradient(-45deg, #8c7814 0%, #a99118 100%)"
panel.Style.Add("background-image", backgroundImage);
导致:

panel.Style.Value

提供了什么?

我建议您在css类中添加这些样式

"background-image:url(http://path/alert.png),%20linear-gradient(-45deg,%20#8c7814%200%,%20#a99118%20100%);"
然后

.newClass
{
    background-image:url(http://path/alert.png);
}

根据DavePerson的建议,切换到“背景”速记是解决这一问题的关键。

出于兴趣,它是否也适用于其他样式?也许框架看到的是
背景图像
样式,假设一个url并转义该值?你试过背景风格吗?@NathanLee:在哪里添加?我尝试了背景图像。替换(“,”);但结果也是一样的。@DaveParsons啊哈!背景大小实际上没有这个问题。我将尝试背景风格。我能用它来完成我现在所做的事情吗(背景图像、背景位置、背景大小、背景重复)?@ChristoferOlsson:有一种方法可以找到。是的,对不起:)我现在已经切换到背景,它几乎就是我想要的了。我从这里开始。谢谢。但是这些值是动态创建的。
panel.CssClass="newClass";
string backgroundImage = "linear-gradient(-45deg, #8c7814 0%, #a99118 100%)";
panel.Style.Add("background", backgroundImage);