473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

if statment (assistance)

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

Jan 9 '06 #1
2 1026
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

Jan 9 '06 #2
VJ
Thanks Mark.

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Jan 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: e_AK_05 | last post by:
I have a question and I can't figure out how to do it. I have a select statment : SELECT table1.* AS table1.*, table2.* AS table2.* FROM table1, table2 WHERE 1 this does not work...for me at...
1
by: Joe Saliba | last post by:
Hi, would like to know how to write a crosstable select statment in sql server2000 where having: - ItemNumber, ItemDescription, ItemColor, ItemSize as rows - Stores as columns - Qty * Netttc...
9
by: Appel | last post by:
Hallo i have a problem to add to string with a SQL statement. My Table : Tablename NAMES: | Name1 | Name2 | Name3 | John Meyer I search for a SQL statment that update Name3.
1
by: Me, Myself, and I | last post by:
First off, i apologize if my terminology is off... I am currently in a project that is basically a front-end to a database. In coding this, I am taking into account that it has the *potential*...
2
by: mc | last post by:
I'm writing a C# asp.net webpage. I have a SQL connection and command inside using statements (as below), if I do a response.redirect inside it will the auto-disposal code execute? using...
5
by: vsteshenko | last post by:
Hello, This is my second post to the any usernet group and the first one was posted to the wrong one. I am currently working on creating an order form for sales associates at my work to be used...
4
by: huzzaa | last post by:
I am using a switch statement that will decide from a random number what message to display. I want the random number to be between 0 and 100 and then if the number is say between 1 and 10 to...
1
by: zeebiggie | last post by:
Good morning I have a form with the controls in the insert statment below. table1 has an Auto increment primary key hence is omitted in the insert statment and form. Am getting the error It didnt...
10
by: allik7 | last post by:
I am have a problem with this section of code. When I place the select statemnet in a string variable i get an syntax error at RTRIM. Can the Case section be used in a string variable i am wondering...
3
by: gaurav92K | last post by:
sir i am working in a company . there are many pc. i want to use remote assistance. i configure all group policy which are related remote assistance.and i enable service through remote in system...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.