Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.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
Javascript 获取插入到src和href属性中的Razor数据_Javascript_Asp.net Mvc_Iframe_Razor_Umbraco - Fatal编程技术网

Javascript 获取插入到src和href属性中的Razor数据

Javascript 获取插入到src和href属性中的Razor数据,javascript,asp.net-mvc,iframe,razor,umbraco,Javascript,Asp.net Mvc,Iframe,Razor,Umbraco,我需要在iframe元素的src属性中插入一个API键和一个位置字符串 以下是我的iframe的外观: <iframe class="center-block" src="https://www.google.com/maps/embed/v1/place?key=@Umbraco.Field('aPIKey')&q=@Umbraco.Field('lokation')" width="95%" height="300" frameborder="0" style="border:

我需要在iframe元素的src属性中插入一个API键和一个位置字符串

以下是我的iframe的外观:

<iframe class="center-block" src="https://www.google.com/maps/embed/v1/place?key=@Umbraco.Field('aPIKey')&q=@Umbraco.Field('lokation')" width="95%" height="300" frameborder="0" style="border:0" allowfullscreen></iframe>
我尝试将“”用于razor属性,但这会破坏dokument其余部分的格式

我真的很困惑,在HTML属性中使用Razor语法的正确方法是什么

@Umbraco.Field('lokation') @Umbraco.Field('aPIKey')
应该是

@Umbraco.Field("lokation") @Umbraco.Field("aPIKey")
引号用于
c

现在,由于您正在razor中使用
引号,因此需要将html引号更改为

<iframe class="center-block" src='https://www.google.com/maps/embed/v1/place?key=@Umbraco.Field("aPIKey")&q=@Umbraco.Field("lokation")' width="95%" height="300" frameborder="0" style="border:0" allowfullscreen></iframe>

应该是

@Umbraco.Field("lokation") @Umbraco.Field("aPIKey")
引号用于
c

现在,由于您正在razor中使用
引号,因此需要将html引号更改为

<iframe class="center-block" src='https://www.google.com/maps/embed/v1/place?key=@Umbraco.Field("aPIKey")&q=@Umbraco.Field("lokation")' width="95%" height="300" frameborder="0" style="border:0" allowfullscreen></iframe>


它应该是
@(Umbraco.Field(“lokation”))
-如果您的“变量”包括偏旁词或其他特殊字符,例如“当您已经在一个”分隔的文本字符串中时”,您需要将整个内容封装在…更多偏旁词中:-)

它应该是
@(Umbraco.Field(“lokation”)
-如果您的“变量”包括偏执狂或其他特殊字符,如“当您已经在“-分隔的文本字符串,您需要将整个内容封装在。。。更多的偏执:-)

这对我不起作用,因为格式不正确。太好了,如果你能把它标记为正确的话,我将不胜感激。谢谢。这对我不起作用,因为格式不正确。太好了,如果你能把它标记为正确的话,我将不胜感激。谢谢