Assigning a Session variable to a Const with VBScr
I'm trying to assign a constant variable with asp such as;<BR><BR>Const cName = <%=Session("strName")%><BR><BR>This fails because you can't assign a variable to a constant. How would I perform this action?
...it *does* cost a bit to invoke a so-called session variable.<BR><BR>What you are *actually* obtaining is the value of an entry in a hash table (VB collection, essentially). And, worse, you have to do it via not one but two "default method or property" invocations.<BR><BR>So if you will only use the value one time, sure just get it from the Session.Contents("name").Value [See the two default methods/properties in there? when you simply do Session("name")?].<BR><BR>But if you use it more than once...yes, even twice...you will save time if you assign it to a VBS variable and then use the variable thereafter.<BR><BR>True, you can't assign it to a CONST. So what? It isn't truly a const when it's a Session "variable" anyway, is it? So just assign it to an ordinary variable and slap your own hands if you ever change the variable's value.<BR><BR><BR><BR>