Solved

C#5

Posted on 2012-03-17
2
205 Views
Last Modified: 2012-03-17
Unforunately, I cannot find a code that I can compare my work with.  I have a book but it does not have any hints to the solutions.  So thanks everyone.
So far, I have done what everyone has said.  I am getting a blank webpage.  I have submitted the HTML page to the Default.aspx.  I am not getting anymore scripting errors.  Thanks.  Now, Am i ready for the Default.aspx?  I will begin working on it now.

<!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>
  </head>
<body>
    <script runat="server" >
        void Text1_onclick(object sender, EventArgs e)
        {
        }
        void Text1_onclick(object sender, EventArgs e)
        {
        }
        void Submit1_onclick(object sender, EventArgs e) {
             if (Text1.Value.Length < 1)
             {
                string error = "Please Enter a value in Hours Field ";
                string script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script , true);

              }
            else if(Text2.Value.Length < 1)
             {
                ststring error = "Please Enter a value in Pay Rate Field";
                string script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script , true);

              }
            else
             {
                double hours = Convert.ToDouble(Text1.Value);
                double rate = Convert.ToDouble(Text2.Value);
                MessageBox.Show(string.Format("Your Gross Pay is $ {0}" ,hours - 40 * rate * 1.5));
             }
       </script>
    <form action="Default.aspx" method="post">
    <p>Enter Hours Worked:<input id="Text1" type="text" onServerClick="Text1_onClick" /></p>
    <p>Enter Pay Rate:<input id="Text2" type="text" onServerClick="Text2_onClick" /></p>
    <p><input id="Submit1" type="submit" value="submit" onServerClick="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: 37733954
You are getting closer. Still some problems.

1.) You cannot access the value of Text1 or Text2 from the server code unless you have the runat="server" attribute inside the input tags. I've said this multiple times in other questions.

2.) Again, the submit button will not run the code on the server unless you have the runat="server" attribute in that input tag.

3.) Your form will not submit back to the server and run the code unless you have a runat="server" attribute in the form tag.

4.) Again and again, MessageBox.Show does not work on a Web form. Use an alert box like you have done in the if/else if.

5.) You have a syntax error in your script. The closing curly brace ( } ) is missing for the click event handler.

6.) The onServerClick calls are not going to work in the TextBoxes. TextBoxes do not have a click event. That was partly my fault from the previous question. Tell me what you are planning to do with those events and I can help with those.
0
 

Author Comment

by:assaultkitty
ID: 37733996
Thank you.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

832 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