小编Arb*_*æde的帖子

如何在foreach期间将自定义列添加到表中

您好我需要构建动态表,其中包含来自数组的列(标题)和来自其他数组的行,数组中的第一列必须是静态的.

<table>
<thead>
<tr>
<th>Static</th>
<th>Dynamic 1</th>
<th>Dynamic 2</th>
<th>Dynamic 3</th>
</tr>
</thead>
<tbody>
<tr>
<th>Nam1</th>
<th>value</th>
<th>value</th>
<th>value</th>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

我有下一个Knockout HTML模型allRoles这是带有动态标头的数组

<table>
            <thead>
                <tr data-bind="template: { name: 'tableHeader', foreach: allRoles, as: 'role',afterRender: addFirstColumn } ">                                                  

                </tr>
            </thead>    
                <tbody data-bind="foreach: {data: userRoles,as:'dep'}">
                <tr>
                    <td>
                       <span data-bind="text: dep.name"></span>
                    </td>                   
                    <td data-bind="foreach: {data: dep.roles, as: 'role'}">
                       <span data-bind="text: role.id"></span>
                    </td>
                </tr>
                </tbody>
            </table>


<script type="text/html" id="tableHeader">
    <th data-bind="text: role.name">

    </th>
</script>
Run Code Online (Sandbox Code Playgroud)

我怎么能添加静态?

javascript knockout.js

4
推荐指数
1
解决办法
4137
查看次数

Web Api,如何从HttpResponseMessage返回枚举文本值而不是枚举索引值

我注意到我的Web Api方法返回HttpResponseMessage将枚举值转换为int(值的顺序).但我想返回枚举文本值.

return Request.CreateResponse(HttpStatusCode.OK, new {MyEnum.Someting, MyEnum.Someting2});
Run Code Online (Sandbox Code Playgroud)

我应该为它设置什么?

c# enums asp.net-web-api

4
推荐指数
1
解决办法
4263
查看次数

Sitecore项目不包含所有字段,为什么?

我有下一个代码(就像原型一样)

 private void WriteDataToItems(Item rootitem, IQueryable<LanguageData> languageData, SC.Globalization.Language sclng)
        {
            if (rootitem == null)
                return;
            rootitem = IncVersion(rootitem);
            Response.Write(string.Format("Item {0} - {1}<br/>", rootitem.DisplayName, rootitem.Paths.FullPath));
            rootitem.Editing.BeginEdit();
            try
            {
                foreach (Field fld in rootitem.Fields.Where(d => !d.Shared && !d.Name.StartsWith("__") && d.Name.Trim() != ""))
                {
                    Response.Write(string.Format("Processing  fld: - {0}<br/>", fld.ID.Guid.ToString()));
                    var data = languageData.FirstOrDefault(
                            d => (string.Compare(d.FieldName, fld.Name, true) == 0) && (string.Compare(d.ItemID, rootitem.ID.Guid.ToString(), true) == 0));
                    if (data != null)
                    {
                        string newValue = null;
                        switch (sclng.Name)
                        {
                            case "en":
                                newValue = data.En; …
Run Code Online (Sandbox Code Playgroud)

sitecore sitecore6

3
推荐指数
1
解决办法
2318
查看次数

如何使用Sitecore MVC设置Ioc(Autofac)

有没有人知道如何设置正确的IoC(Autofac)并将其与Sitecore MVC一起使用?我已经创建了一个特定的Pipeline,但是当sitecore渲染页面(Controller rendering)时,解析不起作用.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <pipelines>
            <initialize>
                <processor type="MyLib.AutofacProcessor, MyLib" />
            </initialize>
        </pipelines>
    </sitecore>
</configuration>
Run Code Online (Sandbox Code Playgroud)
public class AutofacProcessor
{
    public void Process(PipelineArgs args)
    {
        AutofacProcessor.Start();
    }

    public static void Start()
    {
        var builder = new ContainerBuilder();
        builder.RegisterType<MyService>().As<IMyService>().PropertiesAutowired();

        var container = builder.Build();
        IDependencyResolver resolver = new AutofacDependencyResolver(container);
        DependencyResolver.SetResolver(resolver);
    }
}
Run Code Online (Sandbox Code Playgroud)

但是当sitecore调用它时,我在控制器中的属性为null.如何在Sitecore术语中注册?在常规ASP MVC中,它非常简单.

asp.net-mvc sitecore autofac sitecore8

3
推荐指数
1
解决办法
781
查看次数

2
推荐指数
3
解决办法
9194
查看次数

Json.Net如何将null反序列化为空字符串?

我的class_中有string属性

        [DataMember]
        [JsonProperty(PropertyName = "email")]
        [StringLength(40, ErrorMessage = "The Mobile value cannot exceed 40 characters. ")]
        public string Email { get; set; }
Run Code Online (Sandbox Code Playgroud)

由于某种原因,在Convert.Deserialize过程中,我需要在此属性中使用空字符串而不是null,以防此值未在JSON对象中设置.怎么做 ?

asp.net json.net c#-4.0

2
推荐指数
1
解决办法
8037
查看次数

用于任何语言的小写的Javascript测试字符串

嗨,我需要测试javascript字符串为任何较低的后期我已构建下一个代码:

var LOWER = /[a-z]/;
var lower = LOWER.test('mystring');
Run Code Online (Sandbox Code Playgroud)

但如果字符串包含来自其他语言的任何特殊字符,则此代码不起作用.并且是合乎逻辑的,我的测试仅适用于英语.如何为任何语言编写测试?

javascript

2
推荐指数
1
解决办法
65
查看次数

是否可以将web.config中的安全性部分添加到外部文件中

我需要通过配置文件阻止一个巨大的IP列表

<security>
      <ipSecurity allowUnlisted="true">
        <clear />          
        <add ipAddress="1.0.1.0" subnetMask="255.255.255.0" />
        <add ipAddress="1.0.2.0" subnetMask="255.255.254.0" />
        <add ipAddress="1.0.8.0" subnetMask="255.255.248.0" />
        <add ipAddress="1.0.32.0" subnetMask="255.255.224.0" />
        ...
      </ipSecurity>
</security>
Run Code Online (Sandbox Code Playgroud)

是否可以将web.config中的安全性部分添加到外部文件中?

asp.net asp.net-mvc web.config-transform

2
推荐指数
1
解决办法
3214
查看次数

如何通过sitecore rock编辑模板内容属性?

是否可以通过sitecore rock插件为VS编辑内容属性?例如Item Buckets部分 在此输入图像描述

sitecore sitecore-rocks

2
推荐指数
1
解决办法
162
查看次数

如何正确地将 appsettings.json 中的配置对象绑定到用户对象

我在 .net Core 1.1 上启动了一些基本项目,我希望将一些属性从 appsettings.json 映射到对象,但我可能无法理解正确的名称约定或一些非常基本的内容

关于MSDN使用选项和配置对象部分,使用它非常容易。我将下一行添加到 appsettings.json

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  },

  "XXXOptions": {
    "X1": {
      "AppId": "11",
      "AppCode": "22"
    },
    "X2": {
      "AppId": "",
      "AppCode": ""
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我添加了自定义类

 public class XXXOptions
    {
        public XXXOptions()
        {
        }
        public X1 X1{ get; set; }
        public X2 X2{ get; set; }
    }

    public class X1
    {
        public int AppId { get; set; }
        public int AppCode { get; set; }
    } …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core

2
推荐指数
1
解决办法
5544
查看次数