Sunday, 15 January 2012

javascript - doPostback Error -



javascript - doPostback Error -

i trying execute javascript function on page load , postback phone call function in code behind. getting time zone info , trying pass them arguments __dopostback. here have (abbreviated):

in .aspx file

<body onload="getlocaltime()"> .... function getlocaltime(){debugger var d = new date(); var tzoffset = d.gettimezoneoffset(); var hfoffset = document.getelementbyid('<%=hfoffset.clientid%>'); var hftzname = document.getelementbyid('<%=hftzname.clientid%>'); var tzname = gettimezonename(); hfoffset.value = tzoffset; hftzname.value = tzname; __dopostback('tzsessionvars', tzoffset, tzname); }

in code behind's page_load(), if ispostback true:

string starget = request["__eventtarget"]; if (starget.equals("tzsessionvars")) { string sarg = request["__eventargument"]; settzsessionvars(sarg); // parse argument , set session vars }

when trace javascript, when hits __dopostback, says:microsoft jscript runtime error: object expected

the parameters tzoffset , tzname ok , have valid values.

you can utilize __eventargument explained in article.

doing or raising postback using __dopostback() function javascript in asp.net

try passing concatenated values single __eventargument , split @ server actual arguments

javascript asp.net

No comments:

Post a Comment