Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C#2

Posted on 2012-03-17
2
Medium Priority
?
307 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

722 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