Click here to Skip to main content
15,867,997 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my project I' m using the Javascript code for getting the User name, it will work fine in Internet Explorer, but the txtUsernName is not getting if I use fire fox Browser, is there any separate code for firefox browser...

I serached in Google, but i didn't get the answer,
I hope I vl get the answer from here..

var txtuser= document.getElementById('<%= txtUserName.ClientID %>').value;


Thanks & Regards
Honey.
Posted
Updated 29-May-12 0:56am
v2
Comments
Bojjaiah 29-May-12 7:05am    
your code is abviously correct? once again check it.
or post entire code we can check it.

You can try

JavaScript
var txtUsName = document.getElementById('<%= txtUserName.ClientID %>');
txtUsName.value = "User Name";


this line should be written after your HTML Tags
 
Share this answer
 
1. I suggest you try separating it like this

JavaScript
var txtBox = document.getElementById('<%= txtUserName.ClientID %>');
txtBox.value = "Any value";


I found this to work sometimes I am not sure why and not sure whether it will in your case but you can try.

Also, I think you should start using jQuery because it has use the implementation according to the users browser so we have to worry less about browser dependency COMPARATIVELY if we sue jQuery.

like in jQuery the methos like

JavaScript
$('#txtBox').val("Any value");


will work on all browsers.
 
Share this answer
 
var txtUsername=document.getElementById('<%= txtUserName.ClientID %>').value

alert(txtUsername);//You get the value what u have written in textbox
 
Share this answer
 
Comments
honey4bee 29-May-12 6:58am    
Using ur suggested code also i didn't get the username value,
[no name] 29-May-12 7:07am    
where u write ur javascript in function or any event
[no name] 29-May-12 7:49am    
Show me your HTML

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900