Solved

C#5

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Suggested Solutions

Title # Comments Views Activity
innerHTML 7 35
Obtain data from database .mdb 4 19
ASP.NET Content Page 3 31
I need help setting tabindex to textboxes in my MVC.Net application 3 13
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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 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