Don't try it this way. First, you need to call the memberFun function from
somewhere else in your code, such as the Page_Load event. If you were trying
to conditionally create the function, you would receive an error because the
compiler wouldn't be able to find the function memberFun and wouldn't know
why. You really don't need to conditionally create functions, you simply
wrap the appropriate content in a conditional check. For example:
void memberFun()
{
if ((Session["MemberQuantity"] != null) &&
(Session["MemberQuantity"].ToString() != "0"))
{
Response.Write(Session["MemberQuantity"] + " Young Friend Member
Ticket(s) at " + Session["MemberCost"]);
}
}
I also changed the conditional check slightly. First, you always need to
test things like Session variables for a null value. What happens if the
particular Session variable doesn't exist? The compiler will throw a
nullreference exception so you always need to check for that first. Also,
when checking to see if is equal to a string, it's best to make sure that
you call the ToString() method of the item to ensure that the item stored
there is actually a string. Session variables can have more than one type of
content stored in them and the compiler may often scream at you.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
<vn****@hotmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
I'm passing testing for a session variable
if (Session["MemberQuantity"] != "0")
void memberFun()
{
Response.Write(Session["MemberQuantity"] + " Young Friend Member
Ticket(s) at " + Session["MemberCost"]);
}
}
the Session["MemberQuantity"] comes from
<select><option>value</option></select>
if the variable is not "0"... then create the void class...
thanks