Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

How not to hard code this value OR add a check for null?

I made this Javascript change in this new project and hard coded a value. I didnt know this JS code is used for other sections as well. So, now this hardcoded value is NULL for another page...

How can either not hard code this OR do a check for a null?

-- you see that "ctl00_Body_grdOrderItems".... for another page, that value is "ctl00_Body_grdAllOrders" ... so this hardcoded value wont do it...
function EditSelectedObject (sender, eventArgs) 
{  
    var masterTable = $find("ctl00_Body_grdOrderItems").get_masterTableView();
   ....
 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of dctuck
dctuck
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Camillia

ASKER

var grd = $find("ctl00_Body_grdOrderItems");
if(grd != null)

That means is grd IS NOT null? if it's null...i want to execute the next statement..so it should be...

if (grd = null)  .... no?
it should be if(grd == null)

grd = null sets the value of grd to null
grd == null means grd equals null
Yes, (grd != null) means IS NOT null, but you would need (grd == null) to check if grd IS null