Hello,
Do I have to use a DynamicForm for calling a web service?
For example, I want to extract a field from a database and I use this code:
isc.DynamicForm.create({
ID:"inputForm",
left:10, top:40, width:275,
items:[
{name:"sql", title:"SQL string", type:"string", required:true}
],
extract : function() {
if (!this.validate()) return;
if (!this.service) {
isc.say("Please try again in a moment - still loading web service descriptor");
return;
}
var sql = this.getValue("sql");
this.service.callOperation("ExtractField", {sqlstring:sql},
"ExtractFieldResponse", "FtoC.setData(data[0])");
}
});
isc.IButton.create({
ID:"runButton",
left:275, top:40,
title:"Run Command",
click:"inputForm.extract()"
});
I write my SQL command in the input text box, then, by clicking a button, I call “ExtractField”, a Web method (written in c#) that connects to an Oracle database and extracts a field according to my SQL command.
How can I define the “extract” function for my button, without using the dynamic form? And also I don’t want to write the SQL command in the input text box, I want to insert it in the code as a parameter, is that possible?
More general… what I actually wanted to ask is:
How can I call a C# method from any SmartClient control? (e.g. when clicking a button, a record in a listgrid or in a treegrid)
I am integrating SmartClient with Visual Studio.NET 2003 and I need C# functions to connect to an Oracle database. I don’t know how to write those functions in JavaScript, so I try to access C# functions through a web service.
But the problem is I tried this code:
isc.IButton.create({
ID:"runButton",
left:275, top:40,
title:"Run Command",
click: function() {
if (!this.validate()) return;
if (!this.service) {
isc.say("Please try again in a moment - still loading web service descriptor");
return;
}
var sql = "select username from users where iduser=245";
this.service.callOperation("ExtractName", {sqlstring:sql},
"ExtractNameResponse", "FtoC.setData(data[0])");
}
});
isc.DetailViewer.create({
ID:"FtoC",
left:10, top:150, width:400, height:20,
emptyMessage:" ",
fields:[
{name:"ExtractNameResult", title:"SQL command result"}
]
});
isc.XMLTools.loadWSDL("http://localhost/WebService1/Service1.asmx?WSDL",
"runButton.service = service");
And I get this error: “Object doesn’t support this property or method”. What did I do wrong? Doesn’t the button have the “service” property?