Hi All,
I am using AJAX to populate a textbox(txtFac) based on the values
in a dropdown(ddlyear) and a textbox(txtproj) on click of a
button(btnView).
Problem is:- The AJAX method isn't called
Code in the javascript
eh.addEvent($("btnView"), 'click', function() {
fnValidate();
}, false);
function fnValidate()
{
var varInvtyr =
frmGiEiaEdit.document.getElementById("ddlyear");
var varGIProject =
frmGiEiaEdit.document.getElementById("txtProj");
if(varInvtyr.options[varInvtyr.selectedIndex].text==" ")
{
alert("Select a year");
return false;
}
else if(varGIProject.value.length == 0)
{
alert("Enter a project Value");
return false;
}
else
{
getGiEiaValues();
}
}
function getGiEiaValues()
{
var
varInvtYrValue=frmGiEiaEdit.document.getElementById("ddlyear");
var varGIProjectValue =
frmGiEiaEdit.document.getElementById("txtproj");
//Calling Method in Ajax , this isn't getting called
GIEIAMethods.GetGIEIAData(varInvtYrValue.options[varInvtYrValue.selectedInd ex].text,getFieldTableCallback);
}
function getFieldTableCallback(response) {
if (response.error) {
alert("GiEiaValues error: " + response.error.Message);
}
else {
alert("else - getFieldTableCallback");
var org = $("txtFac");
if (org) {
var table = response.value;
if (table && table.Rows && table.Rows.length == 1) {
//Name of the Column which i want to populate in
textbox EIAFactor
var varEIAFactor = table.Rows[0].EIAFactor;
if (varEIAFactor)
{
org.text=varEIAFactor;
}
}
}
}
}
Code in Ajax
<AjaxPro.AjaxNamespace("GIEIAMethods")> _
Public Class GIEIAMethods
<AjaxPro.AjaxMethod()> _
Public Function GetGIEIAData(ByVal InvtYr As Short) As DataTable
//Hard coded the value for time being
Return DataAccessTier.GIEIADataMethods.GetGIEIAData(InvtYr,
"0000345")
End Function
End Class
I registered this namespace in .aspx.vb file
AjaxPro.Utility.RegisterTypeForAjax(GetType(GIEIAMethods))