Firefox issue with ASPNET AJAX

S

Showjumper

Hi,
I am using ASP.NET AJAX to check username availability in a registration
form. Everything works fine in IE but not in FF. Using Firebug, i can find
the offending line but not sure what to about it. The error firebug gives
txtUsername has no properties. Not sure how to fix this. Thank you for any
help.

var txtUserName;

function pageLoad()

{

txtUserName = $get("<%=Username.UniqueID %>");

}



function CheckUserName()

{

if (txtUserName.value.length > 0)

{

$get("imgWaitingUsername").style.display = 'inline';

$get("spanUsername").innerHTML = 'Checking Username Availability...';

$get("spanUsername").style.color = "red";

$get("spanUsername").style.fontWeight = "bold";

PageMethods.CheckUserName(txtUserName.value, OnCheckUserName);


}

else

$get("spanUsername").innerHTML= "";

reqvalUsername.innerHTML = "Username is required";


}
 
L

Laurent Bugnion, MVP

Hi,
Hi,
I am using ASP.NET AJAX to check username availability in a registration
form. Everything works fine in IE but not in FF. Using Firebug, i can find
the offending line but not sure what to about it. The error firebug gives
txtUsername has no properties. Not sure how to fix this. Thank you for any
help.

Which is the offending line?

You have a missing '{' on the line indicated by "HERE" (see below).

You should really start to indent your code and use a consistent code
guideline, it would make your code easier to read and to debug.

HTH,
Laurent
 
S

Showjumper

Error in Firebug is txtUserName has no properties. Offending line appears to
be
if (txtUserName.value.length > 0)
Took care of the missing bracket and it still does not work in FF but works
in IE.
Also My code IS indented in VS.
Laurent Bugnion said:
Hi,
Hi,
I am using ASP.NET AJAX to check username availability in a registration
form. Everything works fine in IE but not in FF. Using Firebug, i can
find the offending line but not sure what to about it. The error firebug
gives txtUsername has no properties. Not sure how to fix this. Thank you
for any help.

Which is the offending line?

You have a missing '{' on the line indicated by "HERE" (see below).

You should really start to indent your code and use a consistent code
guideline, it would make your code easier to read and to debug.

HTH,
Laurent
var txtUserName;

function pageLoad()

{

txtUserName = $get("<%=Username.UniqueID %>");

}



function CheckUserName()

{

if (txtUserName.value.length > 0)

{

$get("imgWaitingUsername").style.display = 'inline';

$get("spanUsername").innerHTML = 'Checking Username Availability...';

$get("spanUsername").style.color = "red";

$get("spanUsername").style.fontWeight = "bold";

PageMethods.CheckUserName(txtUserName.value, OnCheckUserName);


}

else
HERE


$get("spanUsername").innerHTML= "";

reqvalUsername.innerHTML = "Username is required";


}

--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
L

Laurent Bugnion, MVP

Hi,
Error in Firebug is txtUserName has no properties. Offending line appears to
be
if (txtUserName.value.length > 0)

That error means that the control named after "<%=Username.UniqueID %>"
doesn't exist on your page. It's null, so when you try to access the
"value" property, it throws an error.

You must find why there is no such control on your produced page. Try to
view the produced HTML source (on the web client) and see if it's here.
Took care of the missing bracket and it still does not work in FF but works
in IE.

That's rather surprising for this error. Compare the produced HTML code
in IE and in Firefox. Do you see differences?

Also My code IS indented in VS.

OK, that's good. I use "Insert spaces" instead of "Keep tabs" in the
"Text editor" options in VSto avoid this kind of annoyance when I
copy/paste code.

HTH,
Laurent
 
S

Showjumper

Fixed the issue: it was the Unique ID reference which worke din IE but not
in FF.
Laurent Bugnion said:
Hi,
Error in Firebug is txtUserName has no properties. Offending line appears
to be
if (txtUserName.value.length > 0)

That error means that the control named after "<%=Username.UniqueID %>"
doesn't exist on your page. It's null, so when you try to access the
"value" property, it throws an error.

You must find why there is no such control on your produced page. Try to
view the produced HTML source (on the web client) and see if it's here.
Took care of the missing bracket and it still does not work in FF but
works in IE.

That's rather surprising for this error. Compare the produced HTML code in
IE and in Firefox. Do you see differences?

Also My code IS indented in VS.

OK, that's good. I use "Insert spaces" instead of "Keep tabs" in the "Text
editor" options in VSto avoid this kind of annoyance when I copy/paste
code.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
S

Showjumper

Thanks for your help.
Laurent Bugnion said:
Hi,
Error in Firebug is txtUserName has no properties. Offending line appears
to be
if (txtUserName.value.length > 0)

That error means that the control named after "<%=Username.UniqueID %>"
doesn't exist on your page. It's null, so when you try to access the
"value" property, it throws an error.

You must find why there is no such control on your produced page. Try to
view the produced HTML source (on the web client) and see if it's here.
Took care of the missing bracket and it still does not work in FF but
works in IE.

That's rather surprising for this error. Compare the produced HTML code in
IE and in Firefox. Do you see differences?

Also My code IS indented in VS.

OK, that's good. I use "Insert spaces" instead of "Keep tabs" in the "Text
editor" options in VSto avoid this kind of annoyance when I copy/paste
code.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Top