JS调用WinForm方法出问题了,求解
JS代码如下
JScript code
function addBillInfo() {
//string billID,string count,string btID,string IwTime,string storage,string price
var billID = document.getElementById("txtPiaohao").value;
alert(1);
var count = document.getElementById("txtCount").value;
alert(2);
var btID = document.getElementById("selType").value;
alert(3);
var IwTime = document.getElementById("nowTime").value;
alert(4);
var storage = document.getElementById("selectSM").value;
alert(5);
var price = document.getElementById("txtPrice").value;
alert(6);
window.external.addBillInfoMultiple(billID, count, btID, IwTime, storage, price);
alert(7);
}
Winform代码如下:
[System.Runtime.InteropServices.ComVisible(true)]
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
//添加票据基本信息(循环添加组票据)
private void addBillInfoMultiple(string billID,string count,string btID,string IwTime,string storage,string price)
{
string BillID = billID;
int counts = int.Parse(count);
int btid = int.Parse(btID);
string IWtime = IwTime;
int Storage = int.Parse(storage);
int BillState1 = 0;
for (int i = int.Parse(billID); i <= int.Parse(billID)+counts; i++)
{
BillInfo bi = new BillInfo();
bi.BillID = i.ToString();
bi.B.BID = btid;
bi.IWtime = IWtime;
bi.Storage.SMID = Storage;
bi.Price = double.Parse(price);
bi.BillState1 = BillState1;
BillInfoManager.AddBillInfo(bi);
}
}
点击页面提交按钮后,JS方法运行到alert(6),至调用WinForm方法时提示脚本错误,无法调用addBillInfoMultiple方法或属性,求解~~
谢谢啦 ~~
------解决方案--------------------
供外部调用,怎么也要public 吧
------解决方案--------------------要public的
------解决方案--------------------不是本类使用,要public的。