开发者

Simple JavaScript Question, returning NULL in IE but working in FireFox!

I have this function correctly linked in an external .js file...

 function SubmitAge(age, UpdatePanelID, HiddenAgeID) {
  $get(HiddenAgeID).value = age;
  __doPostBack(UpdatePanelID);
 }

and am calling it like this from an onClick of an a href="#" ... html tag

(tags removed, please scroll right as stackoverflow has the greatest difficulty in displaying simple content, 7th display related edit, thanks stackoverflow)

a href="#" onclick="SubmitAge(24, 'ctl00_MainContent_arFrom_upAgeRange', 'MainContent_arFrom_HiddenAge')" runat="server" 24 /a 

yet, i am getting this error, and its being called on the first line of the SubmitAge function (line with $get(HiddenAgeID)... etc...)

Error:
Microsoft JScript runtime error: 'null' is null or not an object

i've copied and pasted my WATCH windows in visual studio .net (vs2010 beta 2 using vb.net & c#) while the execution breaks inside teh SubmitAge .js function...

  age 53开发者_高级运维 Number
  UpdatePanelID "ctl00_MainContent_arTo_upAgeRange" String
  HiddenAgeID Undefined identifier Error

Why on earth is HiddenAgeId, clearly passed just like UpdatePanelID, is returning an "Undefined identifier Error"??? its perplexed me to the point where i have no room to move! have i missed something guys? thanks - your help or pointers is greatly appreciated.

edit: Update: turns out it works perfectly (as it should) when i load it up in FireFox, but has the resulting error in Internet Explorer, this is not a browser compatibility issue, it should also work in IE, but it doesn't!


How is this method being called? It's possible you are mistakenly only calling the method with two parameters (javascript allows this, and the third parameter would just be undefined within the method body). Or it's possible you really are passing in an undefined value and not realizing it.

Ah you just edited the question. In that case, check to see what $get(HiddenAgeID) is returning, it's probably returning null because it can't find it.


Taking into account any possible ID munging due to naming containers, is MainContent_arFrom_HiddenAge the correct id on the client for the HiddenAgeID?

Looking at the ID of the UpdatePanel, is the id of HiddenAge supposed to be ctl00_MainContent_arFrom_HiddenAge?


so far, i've determined that this is a bug in internet explorer, it really is not expected behaviour, and it can't be by design under any condition, and i'm almost certain it's a bug. i have tried everything from rearranging js function arguments to adding dummy arguments, and restarting internet explorer, visual studio and the computer several times with no luck.

so, i've decided to put the entire functions contents directly into the onclick="(lines of code" event attribute, which means that for every single page on my website, the entire functions lines of code will have to be re printed 110 times (a good 20 to 30 KB of download for users)... this is for the time being anyway, until i have the time to find a better solution.

does anyone know if we can give the correct department's bug report team a link or a pointer to this thread so that they may at least investigate and fix this problem for the betterment of the product? i'm not entirely sure if it's a vs or ie issue, but i think they would both be concerned by this. am willing to provide problem replication help if needed. thank you to everyone for you help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜