如何将javascript中的字符串数组传递给activex [英] How to pass string array in javascript to activex

查看:83
本文介绍了如何将javascript中的字符串数组传递给activex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我们想要设计打印字符串数组的Activex,但是如何将数组旁路到printcontroleventhandler,如下所示,因为这是委托:



Hi all
we wanna Design the Activex that print array of string , but how to bypass array to the printcontroleventhandler as follow , because this is delegate:

[ComVisible(true)]
        public string CreatePrint(Int16 iPrintCount,string[] arr)
        {
            try
            {
                this.Doc = new PrintDocument();
                this.Doc.PrintPage += new PrintPageEventHandler(this.PrtPage(arr));
                this.Doc.Print();
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }





但arr []是错误的参数。



我尝试了什么:



我在传递唯一字符串正确但传递数组时测试以下代码是错的。



but arr[] is wrong parameter.

What I have tried:

I test following code just when pass unique string is correct but when pass array is wrong.

推荐答案

请看我对这个问题的评论。



这是我的建议:不要甚至不喜欢做那样的事情。相反,你有一些文明的变种。



如果在客户端出现数据,使用JavaScript生成一些内容进行打印;让用户以通常的方式打印它。



如果服务器端出现数据,使用常用的ASP.NET技术生成一个网页数据,包括直接生成HTTP响应。如果需要,您可以导航到生成的页面。让用户以通常的方式打印页面。



或者,在这两种情况下,您都可以创建一个按钮或其他元素供用户点击。您可以在客户端或服务器端处理此单击(参见上文)。或者,您可以调用 window.print(),使用JavaScript打印一个窗口。但是,这个动作对我来说似乎是多余的,因为它会显示相同的打印对话框并进行常规打印;用户可以在没有您帮助的情况下做的事情如果您认为您的用户不是一个好的浏览器用户,您可以这样做。



-SA
Please see my comment to the question.

Here is my suggestion: don't even play with the idea of doing anything like that. Instead, you have some civilized variants.

If data is emerged on the client side, use JavaScript to generate some content for printing; let the user print it the usual way.

If data is emerged on the server side, generate a Web page out of data using the usual ASP.NET techniques, including direct generation of HTTP response. You can navigate to the generated page if you want. Let the user print the page in the usual way.

Optionally, in both cases, you can create a button or other element to be clicked by the user. You can handle this click either on client side or server side (see above). Optionally, you can call window.print(), to print a window using JavaScript. However, this action seems redundant to me, because it will show same exact print dialog and do the usual printing; something the user could do without your help. You can do it if you think that your user is not a good browser user.

—SA


这篇关于如何将javascript中的字符串数组传递给activex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆