Link to home
Start Free TrialLog in
Avatar of assaultkitty
assaultkitty

asked on

C#9

I need to submit this form to the Default.aspx file.  Have I done all that I need to do?  What is the next step to getting the Default.aspx file ready to display.

<!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>
Avatar of Rajar Ahmed
Rajar Ahmed
Flag of India image

In asp.net , You have to use Response.redirect
<!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 Submit1_onclick(object sender, EventArgs e) {
            string error, script = "";
             double dOutput = 0;
            
             if (Text1.Value.Length < 1 )
             {
                 error = "Please Enter a value in Hours Field ";
                 script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script , true);

              }
             else if (!Double.TryParse(Text1.Value, out dOutput))
             {
                 error = "Please Enter Valid Numbers in Hours Field ";
                 script = "alert(\"" + error + "\");";
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);
             }
            else if(Text2.Value.Length < 1)
             {
                 error = "Please Enter a value in Pay Rate Field";
                script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script , true);

             }

             else if (!Double.TryParse(Text2.Value, out dOutput))
             {
                 error = "Please Enter Valid Numbers in rate Field ";
                 script = "alert(\"" + error + "\");";
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);
             }    
             
            else
             {
               Response.Redirect("default.aspx?Text1=" + Text1.Value + "&Text2=" + Text2.Value);
              }
             }

        </script>
    <form id="Form1"  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>

Open in new window

//----------------------------------------------------------------------------------------------------------------------------------------------
In default.aspx , ADD this ..
<script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                alertOnDefaultPage();
            }
        }
        void alertOnDefaultPage()
        {
            string error, script = "";
            double dOutput = 0;
            string Text1_qs = Request.QueryString["Text1"];
            string Text2_qs = Request.QueryString["Text2"];
            if (Text1_qs.Length < 1)
            {
                error = "Please Enter a value in Hours Field ";
                script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);

            }
            else if (!Double.TryParse(Text1_qs, out dOutput))
            {
                error = "Please Enter Valid Numbers in Hours Field ";
                script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);
            }
            else if (Text2_qs.Length < 1)
            {
                error = "Please Enter a value in Pay Rate Field";
                script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);

            }

            else if (!Double.TryParse(Text2_qs, out dOutput))
            {
                error = "Please Enter Valid Numbers in rate Field ";
                script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);
            }

            else
            {
                double hours = Convert.ToDouble(Text1_qs);
                double rate = Convert.ToDouble(Text2_qs);
                script = "alert(\"" + String.Format("Your Gross Pay is $ {0}", hours - 40 * rate * 1.5) + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);
            }
        }
    </script>

Open in new window

Avatar of assaultkitty
assaultkitty

ASKER

I am sorry that I have an error on this program.  Also, i need an HTML page and a Default.aspx file.  I did not under stand the ASP. NET  document.
This is a copy of the error.  I rebuilt the form and got tis error.
error.docx
Default.aspx ..
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
    <title></title>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                alertOnDefaultPage();
            }
        }
        void alertOnDefaultPage()
        {
            string error, script = "";
            double dOutput = 0;
            string Text1_qs = Request.QueryString["Text1"];
            string Text2_qs = Request.QueryString["Text2"];
            if (Text1_qs.Length < 1)
            {
                error = "Please Enter a value in Hours Field ";
                script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);

            }
            else if (!Double.TryParse(Text1_qs, out dOutput))
            {
                error = "Please Enter Valid Numbers in Hours Field ";
                script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);
            }
            else if (Text2_qs.Length < 1)
            {
                error = "Please Enter a value in Pay Rate Field";
                script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);

            }

            else if (!Double.TryParse(Text2_qs, out dOutput))
            {
                error = "Please Enter Valid Numbers in rate Field ";
                script = "alert(\"" + error + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);
            }

            else
            {
                double hours = Convert.ToDouble(Text1_qs);
                double rate = Convert.ToDouble(Text2_qs);
                script = "alert(\"" + String.Format("Your Gross Pay is $ {0}", hours - 40 * rate * 1.5) + "\");";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "myScript", script, true);
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    </form>
</body>
</html>
Sorry got the following error.  I hope you are up this time of night.
error.docx
i think linq are not supported in your framework . please remove that line .
I am working on it right now.  I do not see a line that says linq.  It says that the error  is on
this line. Isn't the System.linq in the class file.  So, how do I change that I do not have a class file.

This is the error.

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)

Source Error:

 

Line 1:  using System;
Line 2:  using System.Collections.Generic;
Line 3:  using System.Linq;
Line 4:  using System.Web;
Line 5:  using System.Web.UI;
 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
ASKER CERTIFIED SOLUTION
Avatar of Rajar Ahmed
Rajar Ahmed
Flag of India 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
these are the errors.  I do  not know what is happening here.  We seem to be moving backwards.  

Warning      6      Variable declaration without an 'As' clause; type of Object assumed.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      7      
Warning      1      Validation (XHTML 1.0 Transitional): This name contains uppercase characters, which is not allowed.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\HTMLPage.htm      48      57      C:\...\Testing\
Warning      3      Validation (XHTML 1.0 Transitional): This name contains uppercase characters, which is not allowed.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\HTMLPage.htm      49      53      C:\...\Testing\
Warning      5      Validation (XHTML 1.0 Transitional): Element 'html' is missing the '>' character from its closing tag.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      65      3      C:\...\Testing\
Error      8      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      8      
Error      10      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      10      
Error      12      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      12      
Error      13      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      13      
Error      15      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      15      
Error      16      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      16      
Error      17      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      17      
Error      18      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      18      
Error      19      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      19      
Error      21      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      21      
Error      25      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      26      
Error      27      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      28      
Error      31      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      32      
Error      33      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      34      
Error      37      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      39      
Error      39      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      42      
Error      43      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      46      
Error      45      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      49      
Error      46      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      50      
Error      47      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      51      
Error      50      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      54      
Error      51      Syntax error.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      55      
Error      9      Statement cannot appear outside of a method body.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      9      
Error      20      Statement cannot appear outside of a method body.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      20      
Error      22      Statement cannot appear outside of a method body.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      22      
Error      26      Statement cannot appear outside of a method body.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      27      
Error      28      Statement cannot appear outside of a method body.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      29      
Error      32      Statement cannot appear outside of a method body.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      33      
Error      34      Statement cannot appear outside of a method body.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      35      
Error      38      Statement cannot appear outside of a method body.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      41      
Error      40      Statement cannot appear outside of a method body.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      43      
Error      44      Statement cannot appear outside of a method body.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      48      
Error      7      End of statement expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      7      
Error      11      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      11      
Error      14      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      14      
Error      23      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      23      
Error      24      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      24      
Error      29      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      30      
Error      30      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      31      
Error      35      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      36      
Error      36      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      37      
Error      41      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      44      
Error      42      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      45      
Error      48      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      52      
Error      49      Declaration expected.      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Chapter\Testing\Default.aspx      53
what are these errors ? How it all came suddenly u seem to move far away from the question u have asked .  kindly run my file in a separate solution . I guess your having errors in the solution you are running .
Can you give me a scene shot of your output from this solution?  I ran it in a different file and there are still 45 errors.  Sorry.  I still need your help because you are the expert.
Just download my application using this link and run the application
http://www.filedropper.com/samplecsharp

Hope this helps

Meeran03
Step2GrossOnDefaultPage.png
step1Submit.png
Soemthing must be wrong with my IDE.  Thank you so much.
I have a problem getting this program on my system.  I need urgent help.  Can you help me?   Please configuration error.

Server Error in '/Paycheck' Application.
--------------------------------------------------------------------------------

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.

Source Error:


Line 14:                               <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
Line 15:                               <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup></sectionGroup></sectionGroup></configSections><system.web>
Line 16:             <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
Line 17:                   <assemblies>
Line 18:                         <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
 

Source File: C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.03\Paycheck\web.config    Line: 16


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5448; ASP.NET Version:2.0.50727.5456
remove dat word . Targetframework=4.0
i cannot find it.  Please help.
check in web config
OK