Solved

C#4

Posted on 2012-03-17
15
271 Views
Last Modified: 2012-03-18
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>
0
Comment
Question by:assaultkitty
  • 9
  • 6
15 Comments
 
LVL 7

Accepted Solution

by:
markmiddlemist earned 500 total points
ID: 37733733
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
 

Author Comment

by:assaultkitty
ID: 37733915
Mark how would I do this?  I was told by an expert that this the proper way?  Help!
0
 
LVL 7

Expert Comment

by:markmiddlemist
ID: 37733921
OK, I'll help as much as possible. What is it you are trying to actually do?
0
 

Author Comment

by:assaultkitty
ID: 37733931
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
 

Author Comment

by:assaultkitty
ID: 37733938
As, I can I have a clear example of how the Default page should look?
0
 

Author Comment

by:assaultkitty
ID: 37733990
i am learning thank you!
0
 
LVL 7

Expert Comment

by:markmiddlemist
ID: 37734492
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:assaultkitty
ID: 37734505
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
 
LVL 7

Expert Comment

by:markmiddlemist
ID: 37734547
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
 

Author Comment

by:assaultkitty
ID: 37734570
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
 
LVL 7

Expert Comment

by:markmiddlemist
ID: 37734942
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
 

Author Comment

by:assaultkitty
ID: 37735142
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
 

Author Comment

by:assaultkitty
ID: 37735169
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
 
LVL 7

Expert Comment

by:markmiddlemist
ID: 37735468
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
 

Author Comment

by:assaultkitty
ID: 37735885
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
detecting  the added row index in a datagridview 3 54
What is Thread.Sleep? 5 45
ADO.NET ENTITY DATA MODEL 3 30
DateTimepicker 4 33
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 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

22 Experts available now in Live!

Get 1:1 Help Now