Solved

C#2

Posted on 2012-03-17
2
300 Views
Last Modified: 2012-03-17
Dear sirs:  I am in need of some help here.  I have created the html for this Employee Salary calculator.  I know that I have to create an paycheck.html and a Default.aspx.  I want the submit button to calculate the input for the hours and pay rate.  Can someone help me? I am new to this ASP.NET and Visual Basic.  I am trying to do this on my own just need a little guidance.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
        <title>Paycheck</title>
    <script language="C#" type="text/css">

        function Text1_onclick() {

        }

        function Text2_onclick() {

        }
        void Submit1_onclick(object sender, EventArgs e) {
             if (Text1.Text.Length < 1)
                MessageBox.Show("Please Enter a value in Hours Field ");
             else if (Text2.Text.Length < 1)
                MessageBox.Show("Please Enter a value in Pay Rate Field");
             else if (
             else if
             {
                double hours = Convert.ToDouble(textBox1.Text);
                double rate = Convert.ToDouble(textBox2.Text);
                MessageBox.Show("Your Gross Pay is $" + ("hours - 40 * rate * 1.5");
            }
      </script>
</head>
<body>
    <form action="Default.aspx" method="post">
    <p>Enter Hours Worked:<input id="Text1" type="text" onclick="return Text1_onclick()" /></p>
    <p>Enter Pay Rate:<input id="Text2" type="text" onclick="return Text2_onclick()" /></p>
    <p><input id="Submit1" type="submit" value="submit" onclick="return Submit1_onclick()" /></p>
    </form>
</body>

</html>
0
Comment
Question by:assaultkitty
2 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 37733630
Some of the same problems still exist from your other question on this assignment.

Your text boxes and button cannot be seen by the server without runat="server" attribute.

To get the script to run, it needs to have a runat="server" in the script tag.

Your button would need an onServerClick="Submit1_onclick" not onclick="return Submit1_onclick()"

Standard input textboxes do not have a Text property. Use Text1.Value instead of Text1.Text.

Remove the onclick attributes from textboxes and the code. You don't need them.

Remove the type="text/css" from the script tag.

I suggest you move your script block outside the head section as it has nothing to do with the HTML markup.

MessageBox is something you use in Windows forms, not in asp.net web forms. Print your results and error messages to a label or a javascript alert box.

There are syntax errors in your script. Standard C# format for a i/else if/else block is:

if(condition1)
{
}
else if (condition2)
{
}
else
{
}
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 37733635
your <script> tag should speicfy type="text/C#"

you say "I am new to this ASP.NET and Visual Basic", but the code is written in C#.

what will happen if the user enters a letter in either text box?

the result message box

MessageBox.Show("Your Gross Pay is $" + ("hours - 40 * rate * 1.5");

should show:

MessageBox.Show("Your Gross Pay is $" + hours - 40 * rate * 1.5;


or better:

MessageBox.Show(string.Format("Your Gross Pay is $ {0}" ,hours - 40 * rate * 1.5));

AW
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question