|
PageMethod not being called what ever. I have defined the Shared Function in code behind as below
<system.web.services.webmethod()> _
<system.web.script.services.scriptmethod()> _
Public Shared Function GetCity(ByVal StateCode As String) As DataTable
Dim oDataSet As New DataSet
Dim oCity As New cCity
oCity.STATECODE = StateCode
oDataSet = oCity.GetData
Return oDataSet.Tables(0)
End Function
Below is the script which is in the aspx page which I am using to call the codebehind in the server
<script type="text/javascript">
function jsState()
{
var State = document.getElementById("<%=ddlState.ClientID%>");
document.getElementById("<%=hfselectedIndexState.ClientID%>").value = document.getElementById("<%=ddlState.ClientID%>").selectedIndex
if(State.options[State.selectedIndex].value == "-- Select State --")
{
document.getElementById("<%=ddlCity.ClientID%>").selectedIndex = 0;
document.getElementById("<%=ddlCity.ClientID%>").disabled = true;
}else
{
document.getElementById("<%=ddlCity.ClientID%>").disabled = false;
PageMethods.GetCity(State.options[State.selectedIndex].value,onSuccess_GetCity, onFailed_GetCity);
}
}
</script>
I did try everything I know . Nothing Worked finally I found that its a silly mistake I forgot to add this line the aspx page
<asp:scriptmanager id="ScriptManager1" runat="server" enablepagemethods="true"></asp:scriptmanager>
Thats it It worked.
Thanks!
Murugan
|