Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
.aspx File code to call DDLSubOrdinate_change web method of page.
JavaScript
PageMethods.DDLSubOrdinate_change(vs_HasSubordinatesRoute, nPositionNo, OnSuccess, OnFail);
function OnSuccess(result) {
  v = STP_dist[0]
}


Web Method,:
VB
<WebMethod()> _
                  <System.Web.Script.Services.ScriptMethod()> _
Public Shared Function DDLSubOrdinate_change(ByVal vs_HasSubordinatesRoute As String, ByVal        nPositionNo As String) As String
       Dim wstr As String
       ........................
       ........................
       ........................

       Json_STP = getJson4Table(ds.Tables(0).DefaultView.ToTable, True)
       Json_STP = " var STP=[" + Json_STP + "]" + ";"

       Json_STP_dist = getJson4Table(ds.Tables(0).DefaultView.ToTable(True, StrColumn), True)
       Json_STP_dist = " var STP_dist=[" + Json_STP_dist + "]" + ";"
       Json_STP = Json_STP + vbCrLf + Json_STP_dist
                        
       ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "jstr_STP", Json_STP, True)

Return ""



but after onSuccess of pageMethod i am unable to access variable "STP_dist"
it showing undefined..
please help me...
Posted
Comments
Sampath Lokuge 14-Feb-14 2:51am    
Where you declare it ? Can you put whole code snippet ?

1 solution

JavaScript
function OnSuccess(result) {
     v = STP_dist[0]
}

You need to get returned data from result argument of function, not from STP_dist[0], which seems undefined here.
 
Share this answer
 
Comments
7045Jeegnesh 20-Feb-14 2:13am    
yes i did that.......and it's work
if (result != null && result != "") {
STP = eval(result)[0].STP;
STP_dist = eval(result)[1].STP_dist;
}

but tell me one thing, why pagemethods not allowed any registerscript?
PageMethods are for doing some operation and returning some value to the caller.
Please explore more on it in Google.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900