Tuesday, March 13, 2012

Simple if then else statement

Hello,

I know there is a way to do a simple if then else statement in the aspx
page.
Is was something with the ?-sign.

Can somebody tell me how the syntax was?

Thanks!In VB.NET you use the IIF command. In C# you use ?:

Here are examples of both:

VB.NET:
IIf(TestMe > 1000, "Large", "Small")

C#:
return x != 0.0 ? Math.Sin(x)/x : 1.0;

--
Hope this helps,
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com/blogging

"Arjen" <boah123@.hotmail.com> wrote in message
news:cg37k9$q5o$1@.news5.tilbu1.nb.home.nl...
> Hello,
> I know there is a way to do a simple if then else statement in the aspx
> page.
> Is was something with the ?-sign.
> Can somebody tell me how the syntax was?
> Thanks!
<var> = <conditional expr>?<true part>:<false part>;
Eg:
stsText = (status > 5)?"Moderate":"Poor";

"Arjen" <boah123@.hotmail.com> wrote in message
news:cg37k9$q5o$1@.news5.tilbu1.nb.home.nl...
Hello,

I know there is a way to do a simple if then else statement in the aspx
page.
Is was something with the ?-sign.

Can somebody tell me how the syntax was?

Thanks!

0 comments:

Post a Comment