Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

M going to change label
lblBtkName
text value using below code.

but gives error "object required"

thx in advance.

C#
if (document.getElementById("_ctl0_DOC_TITLE").innerHTML == "MOC") {

    document.getElementById("MOCCheatSheet").style.display = "";
    var lblBtkName = document.getElementById("_ctl1_BTK_NAME");

    var lblBtkDesc = document.getElementById("_ctl1_BTK_DESCRIPTION");
    var lang = GetCookie("SmartLang");
    if (lang.toLowerCase() == "de-de")
    {
        if (lblBtkName.innerHTML.toLowerCase() == "Analyse der Auswirkungen(EMPF)") {
            lblBtkName.innerHTML = "Analyse der Auswirkungen(EMPF)(ACHGDJF)";
        }
    }



   

}
Posted
Updated 7-Apr-14 21:29pm
v4
Comments
Pheonyx 8-Apr-14 3:58am    
1st question: Which line gives the error?
2nd observation: You inner check (lblBtkName.innerHTML.toLowerCase()) will be true as you are not checking it against lower case text.
rizwan muhammed khan gouri 8-Apr-14 5:48am    
Please check cookie is null or not
Master Vinu 8-Apr-14 5:52am    
Pheonyx.... y r right lblBtkName.innerHTML.toLowerCase()) m checking false value


thx bro...

The normal reason for this is that the getElementById methods can't find a control with that name.
So add some checking to lblBtkName to make sure it isn't null - and if it is, check the spelling of the control name and that this code is being used on the correct page!

And Pheonyx is right: you aren't checking lowercase against lowercase...
 
Share this answer
 
Comments
Master Vinu 8-Apr-14 5:52am    
solve ...thx for effrot
OriginalGriff 8-Apr-14 6:07am    
You're welcome!
Which version of .Net are you using?
Note that var is only supported in .Net 3.0 and above[^].
 
Share this answer
 
v3
Comments
Master Vinu 8-Apr-14 5:52am    
thx for efforet... solved
Abhinav S 8-Apr-14 7:58am    
Vote if it helped.

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