PageMethods what is issue with it?
I'm getting "Object Error" on line
function readWURecord()
{
var ifUSD = "";
try
{var mtcnNo=document.getElementById('ctl00_ContentPlaceHolder1_TxtReferenceNo').value;
if(mtcnNo=='')
{
alert('Provide Reference Number');return false;}
var adoConn=new ActiveXObject("ADODB.Connection");
var adoRS=new ActiveXObject("ADODB.Recordset");
var filename;
var filenamecsv1;
fs=new ActiveXObject("Scripting.FileSystemObject");
filename=document.getElementById('ctl00_ContentPlaceHolder1_hdPath').value+'Trans.mdb';
filenamecsv1="D://Data.csv";
if(fs.FileExists(filename)==true)
{
adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+filen开发者_如何学Came+";Persist Security Info=True;Jet OLEDB:Database Password=tradb897");
}
else if(fs1.FileExists(filenamecsv1)==true)
{
PageMethods.GetCurrentTime(document.getElementById("<%=TxtReferenceNo.ClientID%>").value);
and
function OnSuccess(response, userContext, methodName)
{
alert("response");
}
Can anybody help me what issues are with PageMethods.GetCurrentTime method?
First do add some whitspace (indentation) in your code. Secondly "<%=TxtReferenceNo.ClientID%>" will not get resolved if you do not generate a file. And if you have ".js" file then it is static (unless you somehow set it up not to be static).
So you should either set some variable outside of JS (e.g. in your ASP file) and use it in your function or call readWURecord with ClientID parameter or something. Or even better - don't do it in JScript - ActiveX only works in Internet Explorer.
精彩评论