<i id='Bw3op'><tr id='Bw3op'><dt id='Bw3op'><q id='Bw3op'><span id='Bw3op'><b id='Bw3op'><form id='Bw3op'><ins id='Bw3op'></ins><ul id='Bw3op'></ul><sub id='Bw3op'></sub></form><legend id='Bw3op'></legend><bdo id='Bw3op'><pre id='Bw3op'><center id='Bw3op'></center></pre></bdo></b><th id='Bw3op'></th></span></q></dt></tr></i><div id='Bw3op'><tfoot id='Bw3op'></tfoot><dl id='Bw3op'><fieldset id='Bw3op'></fieldset></dl></div>
    <tfoot id='Bw3op'></tfoot>
      <bdo id='Bw3op'></bdo><ul id='Bw3op'></ul>

    <legend id='Bw3op'><style id='Bw3op'><dir id='Bw3op'><q id='Bw3op'></q></dir></style></legend>

    <small id='Bw3op'></small><noframes id='Bw3op'>

    1. 将数组从 C# COM 对象传递给 JavaScript?

      Pass Array From C# COM object to JavaScript?(将数组从 C# COM 对象传递给 JavaScript?)
    2. <tfoot id='6OWIo'></tfoot>

      <small id='6OWIo'></small><noframes id='6OWIo'>

        <bdo id='6OWIo'></bdo><ul id='6OWIo'></ul>

            <tbody id='6OWIo'></tbody>

            1. <legend id='6OWIo'><style id='6OWIo'><dir id='6OWIo'><q id='6OWIo'></q></dir></style></legend>
              <i id='6OWIo'><tr id='6OWIo'><dt id='6OWIo'><q id='6OWIo'><span id='6OWIo'><b id='6OWIo'><form id='6OWIo'><ins id='6OWIo'></ins><ul id='6OWIo'></ul><sub id='6OWIo'></sub></form><legend id='6OWIo'></legend><bdo id='6OWIo'><pre id='6OWIo'><center id='6OWIo'></center></pre></bdo></b><th id='6OWIo'></th></span></q></dt></tr></i><div id='6OWIo'><tfoot id='6OWIo'></tfoot><dl id='6OWIo'><fieldset id='6OWIo'></fieldset></dl></div>
              • 本文介绍了将数组从 C# COM 对象传递给 JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                类似于此 如何将一个字符串数组从 ActiveX 对象返回到 JScript,但在 C# 中.

                Similar to this How do I return an array of strings from an ActiveX object to JScript but in C#.

                我有一个 COM 控件,可以将字符串数组传回 javascript.似乎 javascript 无法理解我要传回的内容,并且 javascript 中的数组始终未定义.

                I have an COM control that passes back an array of strings to javascript. It seems like javascript cant understand what it is I am passing back and the array in javascript is always undefined.

                Javascript:

                Javascript:

                try
                 {
                  keystore.openKeyStore("MY", true, false);
                  var fNames = new Array();
                  fNames = keystore.getAllFriendlyNames();
                  document.getElementById('par').innerHTML = fNames[0];
                 }
                 catch(err)
                 {
                  document.getElementById('err').innerHTML = err.description;
                 }
                

                fNames[0];

                C#:

                    public object[] getAllFriendlyNames()
                    {
                        if (!keystoreInitialized)
                            throw new Exception("Key store has not been initialized");
                
                        X509Certificate2Collection allCerts = certificateStore.Certificates;
                
                        int storeSize = allCerts.Count;
                
                        if (storeSize == 0)
                            throw new Exception("Empty Key Store, could have opened using the wrong keystore name.");
                
                        object[] friendlyNames = new object[storeSize];
                
                        for (int i = 0; i < storeSize; i++)
                        {
                            string friendlyName = allCerts[i].FriendlyName;
                
                            if (friendlyName == "")
                                friendlyName = allCerts[i].Subject;
                
                            friendlyNames[i] = (object) friendlyName;
                        }
                
                        return friendlyNames;
                  }
                

                我试过返回对象数组和字符串数组都无济于事.

                I've tried returning both object arrays and string arrays to no avail.

                推荐答案

                您可以尝试将数据序列化为 json 并在客户端进行反序列化.jQuery 内置了 json 函数.我已经用更复杂的对象做到了这一点,但没有用字符串数组,虽然我敢打赌它会很容易地工作.

                You can try serializing your data to json and deserializing on the client. jQuery has built in json functions. I've done this with more complex objects, but not with string arrays, though I'd bet that it will work just as easily.

                这篇关于将数组从 C# COM 对象传递给 JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                Accessing attribute info from DTE(从 DTE 访问属性信息)
                c# Hide a property in datagridview with datasource(c#使用数据源隐藏datagridview中的属性)
                Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                C# Attributes and their uses(C# 属性及其用途)
                C# - Getting all enums value by attribute(C# - 按属性获取所有枚举值)
                <tfoot id='ubtje'></tfoot>

                <i id='ubtje'><tr id='ubtje'><dt id='ubtje'><q id='ubtje'><span id='ubtje'><b id='ubtje'><form id='ubtje'><ins id='ubtje'></ins><ul id='ubtje'></ul><sub id='ubtje'></sub></form><legend id='ubtje'></legend><bdo id='ubtje'><pre id='ubtje'><center id='ubtje'></center></pre></bdo></b><th id='ubtje'></th></span></q></dt></tr></i><div id='ubtje'><tfoot id='ubtje'></tfoot><dl id='ubtje'><fieldset id='ubtje'></fieldset></dl></div>
              • <small id='ubtje'></small><noframes id='ubtje'>

                    <bdo id='ubtje'></bdo><ul id='ubtje'></ul>

                            <tbody id='ubtje'></tbody>

                          <legend id='ubtje'><style id='ubtje'><dir id='ubtje'><q id='ubtje'></q></dir></style></legend>