By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,990 Members | 1,406 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,990 IT Pros & Developers. It's quick & easy.

Simple form calculation

P: n/a
G
Hello,

I have two form fields:

ID="Field1"
ID="Field2"

And I would like to do the following in CODE BEHIND:

if (Field1 / Field2 0.5)
{
Response.Redirect("MoreThan.aspx")
}

I am unsure of the correct syntax. I would like to store the code as a
function in my Code behind .CS file, and call it when Field2 looses it's
focus after text has been input.

Any help would be appreciated.

Kind Regards,

G.

Jan 24 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

"G" <g@nospam.comwrote in message
news:FD**********************************@microsof t.com...

| I am unsure of the correct syntax. I would like to store the code as a
| function in my Code behind .CS file, and call it when Field2 looses it's
| focus after text has been input.

It would be like:

double f1 = Convert.ToInt32( ((Textbox) Controls.Find( "Field1")).Text);
double f2 = Convert.ToInt32( ((Textbox) Controls.Find( "Field2")).Text);

if ( f1/ f2 0.5 )
...

PLEASE do not use the code above as it is, there is no validation, or
checking of any kind. You first have to verify that both fields exist and
have numeric values.

but it will give you an idea of how it can be done
--
Ignacio Machin
machin AT laceupsolutions com
Jan 24 '07 #2

P: n/a
G
Thanks,

I had already done all my validation controls and other code - this was the
final piece of the puzzle, thanks for solving!!!

G.
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:Ov**************@TK2MSFTNGP02.phx.gbl...
Hi,

"G" <g@nospam.comwrote in message
news:FD**********************************@microsof t.com...

| I am unsure of the correct syntax. I would like to store the code as a
| function in my Code behind .CS file, and call it when Field2 looses it's
| focus after text has been input.

It would be like:

double f1 = Convert.ToInt32( ((Textbox) Controls.Find( "Field1")).Text);
double f2 = Convert.ToInt32( ((Textbox) Controls.Find( "Field2")).Text);

if ( f1/ f2 0.5 )
...

PLEASE do not use the code above as it is, there is no validation, or
checking of any kind. You first have to verify that both fields exist and
have numeric values.

but it will give you an idea of how it can be done
--
Ignacio Machin
machin AT laceupsolutions com

Jan 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.