Solved

C#5

Posted on 2012-03-17
2
209 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
[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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

623 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