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

M going to change label
text value using below code.

but gives error "object required"

thx in advance.

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)";


Updated 7-Apr-14 21:29pm
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.
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...
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[^].
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