Simple form calculation

  • Thread starter Thread starter G
  • Start date Start date
G

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.
 
Hi,


| 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
 
Thanks,

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

G.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top