Link to home
Start Free TrialLog in
Avatar of assaultkitty
assaultkitty

asked on

C#4

This is the error that I am getting in the program can you help and guide me in the right direction?

SCRIPT5009: 'Text2_onclick' is undefined
HTMLPa<!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" >
         function Text1_onclick() {
         }
        function Text2_onclick() {

         }
        void Submit1_onclick(object sender, EventArgs e) {
             if (Text1.Value.Length < 1)
             {
                Response.Write("Please Enter a value in Hours Field ");
              }
            else if(Text2.Value.Length < 1)
             {
                MessageBox.Show("Please Enter a value in Pay Rate Field");
              }
            else
             {
                double hours = Convert.ToDouble(textBox1.Text);
                double rate = Convert.ToDouble(textBox2.Text);
                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" 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" onServerClick="Submit1_onclick" /></p>
    </form>
</body>

</html>
ASKER CERTIFIED SOLUTION
Avatar of markmiddlemist
markmiddlemist
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of assaultkitty
assaultkitty

ASKER

Mark how would I do this?  I was told by an expert that this the proper way?  Help!
OK, I'll help as much as possible. What is it you are trying to actually do?
I am having problems getting the html page to produce the input.  I am assuming that the page is waiting for the default.aspx to be constructed by me.  Therefore, I am going to work on that.  I do not understand why the script should not be runat.  I looked in the book and it says to use the runat.  Can you clarify?
As, I can I have a clear example of how the Default page should look?
i am learning thank you!
Cool. I often recommend at least going through the training for the appropriate Microsoft certifications as a good way to generally upskill. In this case have a look at 70-515 : Web Application development in .net 4 (http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-515) 0 The self paced training kits are excellent. It won't give you a dep dep knowledge, but gives you a good general overview of what tools and techniques you have available to you as a developer, and how to use them.

Are you OK to move on with this yourself, or do you need help still? I'll be online for a fair bit of today so feel free to reply if you do need assistance.

All the best

Mark (@delradie - http://delradiesdev.blogspot.com/)
I still need help.  I am a little confused.  I will book mark this reference and use it. I will be at the computer all day.  I have to turn in my project tonight at 12 AM.
OK, what actually is the brief for this (I'm obviously not going to do the work for you if its for an assigment, but I can point you at the appropriate techniques best with this info)?
This is what I have so far.  I made a mistake on this submission.  I am including a link to the amazon to the book that I am using.  Can you give some ideas to what will help me arrive at my solution.  

This is my reference can you help me?

http://www.amazon.com/ASP-NET-Programming-Server-Technologies/dp/1423903242/ref=sr_1_1?ie=UTF8&qid=1332070105&sr=8-1


<!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)
             {
                string error = "Please Enter a value in Pay Rate Field";
                string script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script , true);

              }
            else
             {
                string error = Convert.ToDouble(Text1.Value);
                string error = Convert.ToDouble(Text2.Value);
                string script = "alert(\"" + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true,
                "Your Gross Pay is $ {0}" ,hours - 40 * rate * 1.5);
             }
             }
       </script>
    <form action="Default.aspx" method="post" runat="server">
    <p>Enter Hours Worked:<input id="Text1" type="text" onServerClick="Text1_onClick" runat="server" /></p>
    <p>Enter Pay Rate:<input id="Text2" type="text" onServerClick="Text2_onClick" runat="server" /></p>
    <p><input id="Submit1" type="submit" value="submit" onServerClick="Submit1_onclick" runat="server" /></p>
    </form>
</body>
</html>
OK, this is actually a way of doing things I'm not familiar with, but rather than confusing you be introducting asp server controls etc, I've just done a quick readup

It looks like there are 2 things (possibly) wrong:

1 - this may not actually be an issue but in the <script runat="server"> you might need to specify the actual language you are using:

<script runat="server" language="C#">

2 - the onserverclick event you are tapping in to is probably only available on the html button, what happens if you remove the onServerClick="TextX_onClick" from the two textboxes?
I am sorry about the break.  I had to write a five page report to turn in to night. I am ready to devote all of my attention to this project.
Step one that you suggested worked but step two brought up a text box. when I clicked the text box.  It is a gray dialog box. Can you help me?

One good thing is that I do not see the compilation errors any more.  I see the HTML page.  I can enter information but once I click the submit button the numbers disappear and the page does not go to the local host.
This is probably down to the action="Default.aspx"  in your form tag - this is telling your form to post to. In order to run your code it actually needs to post to itself, which is the default action so remove that and try again.
Meena06 help me and that is what I currently have for the default.aspx.  I do not see the Default.aspx in the file.  One of the Experts proved to me that this program is working.  So, I am going with it but I am still having problems with getting it to load to my local host.  I think I need some help configuring my IDE.  Can you help me with this issue?  I really need to see what the program looks like for myself.  I am going to post for some help setting up my IDE.