Solved

C#5

Posted on 2012-03-17
2
204 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
Comment Utility
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
Comment Utility
Thank you.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now