Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C#4

Posted on 2012-03-17
15
Medium Priority
?
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
15 Comments
 
LVL 7

Accepted Solution

by:
markmiddlemist earned 2000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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
 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

636 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