DerbyGull Posted September 6, 2012 Share Posted September 6, 2012 I have some javascript code that is in a vb web app. The code works fine when i put it into a HTML table (see below) using the <td>{{field}}</td> syntax in the table statement (not shown) but i now want to put the data into an asp text box and i just can't get it to work. The code i am using for this is below, the 'data' reference is the result from it getting data from a database, it is one record but multiple fields. Old Code, does work. <script type="text/javascript"> var custView; function pageLoad() { custView = Sys.create.dataView("#customersBody"); showCustomers(); $addHandler($get("DropDownList1"), "change" , showCustomers); } function showCustomers() { var country = $get("DropDownList1").value ; Client.CLNorthwindService.GetCustFromAdd(country, showCustomersComplete); } function showCustomersComplete(data) { custView.set_data(data); } </script> New Code, doesn't work. <script type="text/javascript"> function pageLoad() { $addHandler($get("DropDownList1"), "change", showSupplier); } function showSupplier() { var SuppIDs = $get("DropDownList1").value; Client.StockService.GetSuppFromID(SuppIDs, showSupplierComplete); } function showSupplierComplete(data) { document.getElementById("txtSuppName").value = ?????? ; } </script> If i put "Fred" in where the ?????? is it works, but i can'get the data out of 'data' to put in it. Is this the way to go about doing this or is there a way of putting the data into the text box like the HTML table? Link to comment Share on other sites More sharing options...
Ingolme Posted September 6, 2012 Share Posted September 6, 2012 Where's the code where data is set? Link to comment Share on other sites More sharing options...
DerbyGull Posted September 6, 2012 Author Share Posted September 6, 2012 data is set through a web service to another service with the following code: Web Service <WebMethod()> _ Public Function GetSuppFromID(ByVal SuppCode As String) As Service.SupplierDto() Dim svc As New Service.StockService() Return svc.GetSuppByID(SuppCode) End Function vb Service Public Function GetSuppByID(ByVal SuppNo As String) As SupplierDto() Dim dc As New StockDataContext Dim query = From supp In dc.Suppliers Where supp.SupplierID = SuppNo Select New SupplierDto With { .SuppID = supp.SupplierID, .SuppName = supp.SupplierName, .Add1 = supp.Address1, .Add2 = supp.Address2, .Add3 = supp.Address3, .PCode = supp.Postcode, .Contact = supp.Contact, .TheirAcc = supp.TheirAccNo } Return query.ToArray() End Function the db connection is a Linq to SQL Link to comment Share on other sites More sharing options...
Ingolme Posted September 6, 2012 Share Posted September 6, 2012 But none of this is Javascript. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.