Jump to content

Getting values into a text box


DerbyGull

Recommended Posts

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...