我想显示查询字符串(如果它不为空)作为输入字段的值,如<input name="campaign" type="hidden" value="ABC Campaign {% if (QueryString.GetValue("utm_source") != null) { return "| QueryString.GetValue("utm_source")"} %}" />
但由于所有的双引号而无法使其正常工作。我试过用反斜杠来逃避报价但是没有用。你能帮忙吗? (上面的代码放在表单&gt;布局)
中答案 0 :(得分:1)
使用单引号括起整个语句并删除return语句的引号:
value='ABC Campaign {% if (QueryString.GetValue("utm_source") != null) { return QueryString.GetValue("utm_source")} %}'
答案 1 :(得分:0)
{%String.IsNullOrEmpty(查询字符串[&#34; utm_source&#34;])查询字符串[&#34; utm_source&#34;]:&#34;&#34;%}
答案 2 :(得分:0)
您还可以使用其他语法来获取查询参数:
{% !String.IsNullOrEmpty(QueryString.utm_source)?QueryString.utm_source:"" %}
答案 3 :(得分:0)
更短!
(function () {
angular
.module("idCardSupplierWarn", ['mm.foundation', 'security', 'message', "isteven-multi-select"])
.controller('idCardSupplierWarnController', ['$translate', '$scope', 'serviceCockpit','idCardSupplierWarnService', function ($translate, $scope, serviceCockpit,idCardSupplierWarnService) {
var urlSupplierWarningByRefDetail = 'rest/suppliers/warnings/supplier/details';
var self = this;
var params = {} ;
params.idRefNum = idCardSupplierWarnService.getParamIdRefNum();
params.idSupNum = idCardSupplierWarnService.getParamSupNum();
params.codeSuppNum = idCardSupplierWarnService.getParamCodeSupNum();
console.log(params.codeSuppNum);
serviceCockpit.loadData([urlSupplierWarningByRefDetail], params).then(function (results) {
self.suppliersWarningsList = results[0].data;
});
}]);
})();
但如果你想让它有一个|在它之前,你必须使用
{%string.isnullorwhitespace(QueryString.utm_source)? &#34;&#34; :&#34; |&#34; + QueryString.utm_source%}