Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.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# 从C代码后面设置@Font-Face_C#_Css_Asp.net_Font Face - Fatal编程技术网

C# 从C代码后面设置@Font-Face

C# 从C代码后面设置@Font-Face,c#,css,asp.net,font-face,C#,Css,Asp.net,Font Face,在我的样式表中,我声明了 @font-face { font-family: 'light'; src: url('Fonts/HelveticaNeueLTStd-Lt.otf') format('opentype'); } 现在,在我的C代码中,我尝试这样设置类 row.CssClass = light; 但是我得到一个编译错误 当前上下文中不存在名称“light” 是否可以从C代码背后引用css类@font-face 编辑 这就是我试图使用它的方式-我已经尝试了下面的方

在我的样式表中,我声明了

@font-face {
    font-family: 'light';
    src: url('Fonts/HelveticaNeueLTStd-Lt.otf') format('opentype');
}
现在,在我的C代码中,我尝试这样设置类

row.CssClass = light;
但是我得到一个编译错误

当前上下文中不存在名称“light”

是否可以从C代码背后引用css类@font-face

编辑 这就是我试图使用它的方式-我已经尝试了下面的方法

.lightfontface {
    font-family: 'light';
}


@font-face {
    font-family: 'light';
    src: url('Fonts/HelveticaNeueLTStd-Lt.otf') format('opentype');
}

row.CssClass = lightfontface;
我相信你的

row.CssClass = light;
需要

row.CssClass = "className";
您的css将需要一个.className条目

想象一下您的html行:

<tr class="className">stuff</tr>

在样式表上订购很重要。将字体面定义置于.className样式项上方。请参阅:

为什么要在代码隐藏中执行此操作,而不是在HTML中引用样式表?只是asking@trebleCode-因为这是用于导出为pdf时对RadGrid进行格式化-不需要在页面上直观显示,只需要将其以这种方式格式化以便导出-我如何在我的stylesheet.css中定义它?如果我试图添加一个.classnametest{@font-face{font-family:'light';src:url'Fonts/HelveticaNeueLTStd-Lt.otf'format'opentype';}}我在样式规则中得到了一个意外的@block视觉错误。类的css条目不需要@font-face定义,我试图像这样添加一个.className条目。lightfontface{font-family:'light';}-但是如果我试图从我的C调用lightfontface,我会得到一个编译错误“lightfontface”在当前上下文中不存在。您如何从C调用它?在C中,CssClass=stringValue。您在前面的注释中的.lightfontface条目是您的css样式中应该包含的内容sheet@BoJackHorseman不,看来你没有跟着他,哈哈在css中,使您的规则。。
.className { font-family: 'light'; }