Click here to Skip to main content
15,911,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,

I am working on an online shopping website. I need some execute some code only at one time. Actually i want to add Cash On Delivery charge only at one time per order. I have write code but its doesn't work.
Here is code :

C#
if (!IsPostBack)
{
    Single CODCharges = 100;
    NetAmount = cart.Sum(c => c.NetAmount + CODCharges);
}
else
{
    NetAmount = cart.Sum(c => c.NetAmount);
}


It's not work,
help me
thx Thanks to all in advance
Posted
Updated 18-May-12 6:17am
v4

1 solution

I have a whole article devoted to this problem, please read:
Wish You Were Here… Only Once[^].

The technique I invented is quite sophisticated; in part, I planned this work as a kind of computer joke illustrating non-trivial things related to stack, uniqueness, etc. Nevertheless, this is practically well-working code. But I also describe the problem and its "usual" solutions.

—SA
 
Share this answer
 
v3
Comments
Maciej Los 18-May-12 11:21am    
Good answer and article too, my 5!
Sergey Alexandrovich Kryukov 18-May-12 11:23am    
Thank you. That work as a real fun, one of those weird things I do from time to time.
--SA
Shahin Khorshidnia 18-May-12 12:18pm    
+5
Sergey Alexandrovich Kryukov 18-May-12 12:25pm    
Thank you, Shahin.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900