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>
assaultkittyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

markmiddlemistCommented:
The problem you've got is that the functions you are defining are server-side, and so are not rendered to the web browser. I'm assuming here that what you want is to execute the code in the functions on the client. Unfortunately C# cannot be used to write client script, so you will need to remove the runat="server" attribute from the script tag and create javascript functions in there.

There are many many introductory books, webcasts, etc out there on asp.net which should help you undersant this distinction and how to make the framework work for you- have a look at http://www.asp.net/ for a start
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
assaultkittyAuthor Commented:
Mark how would I do this?  I was told by an expert that this the proper way?  Help!
0
markmiddlemistCommented:
OK, I'll help as much as possible. What is it you are trying to actually do?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

assaultkittyAuthor Commented:
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?
0
assaultkittyAuthor Commented:
As, I can I have a clear example of how the Default page should look?
0
assaultkittyAuthor Commented:
i am learning thank you!
0
markmiddlemistCommented:
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/)
0
assaultkittyAuthor Commented:
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.
0
markmiddlemistCommented:
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)?
0
assaultkittyAuthor Commented:
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>
0
markmiddlemistCommented:
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?
0
assaultkittyAuthor Commented:
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.
0
assaultkittyAuthor Commented:
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.
0
markmiddlemistCommented:
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.
0
assaultkittyAuthor Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.