I need to Initialize a value in a Javascript by using a c# literal that makes reference to a Session Variable. I am using the following code
<script type="text/javascript" language="javascript" >
var myIndex = <%= !((Session["myIndex"]).Equals(null)||(Session["myIndex"]).Equals("")) ? Session["backgroundIndex"] : "1" %>;
However the code above is giving me a classic Object reference not set to an instance of an object.
error. Why? Shouldn't (Session["myIndex"]).Equals(null)
capture this particular error?