#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    35
    Rep Power
    0

    Working out a formula from a form


    Hello,

    I am new to .net having come from a PHP background.

    I'm making a small website at the moment in .NET. On one page I have a form with a few fields:

    1st value (let's call it A)
    2nd value (let's call it B)
    3rd value (let's call it C)
    4th value (let's call it D)

    When the user clicks the submit button, it needs to work out the formula:

    (A*4)+(B*3)+(C*4)+D+15

    What is the easiest way to achieve this in .NET? Is it best to use a 'code-behind' model and have the calculations done on another page then displayed on the next webpage?

    Thanks for any help.
  2. #2
  3. Business Analyst
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2004
    Location
    The 'Ville
    Posts
    1,087
    Rep Power
    27
    The MOST VERY BASIC approach is to use the Response.Write() method. That simply writes a line of text. Try something like

    Response.Write("result" + yourCalculatedNumericValue.ToString());

    This is C#. VB syntax is different, but idea is the same.

    And yes, the code-behind is the preferred method for most people. It keeps things neat and clean, and in larger "operation" it can allow designers and developers to modify separate files without stepping on each other's toes.

    Comments on this post

    • davidwhite agrees
    Discontent is the first necessity of progress. - Edison
  4. #3
  5. Business Analyst
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2004
    Location
    The 'Ville
    Posts
    1,087
    Rep Power
    27
    Try this:

    http://support.microsoft.com/kb/303247
    Discontent is the first necessity of progress. - Edison
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    35
    Rep Power
    0
    ok thanks

IMN logo majestic logo threadwatch logo seochat tools logo