ASP.net webpage troubleshooting required

  • Thread starter Thread starter DemiAngel
  • Start date Start date
  • Tags Tags
    Troubleshooting
Click For Summary
SUMMARY

The discussion focuses on troubleshooting an ASP.NET webpage for student marks evaluation. Key issues include syntax errors in the C# code, particularly in the if-else statements and the use of boolean operators. The user is advised to correct the syntax for "else if" and to understand the difference between the boolean operators "||" (OR) and "&&" (AND). Additionally, the user is encouraged to simplify the logic to avoid unnecessary boolean checks.

PREREQUISITES
  • Understanding of ASP.NET Web Forms
  • Familiarity with C# programming language
  • Knowledge of control structures (if-else statements)
  • Basic understanding of boolean logic in programming
NEXT STEPS
  • Review C# syntax for if-else statements and boolean operators
  • Learn about ASP.NET Web Forms event handling
  • Explore debugging techniques in Visual Studio for ASP.NET applications
  • Investigate best practices for form validation in ASP.NET
USEFUL FOR

Web developers, particularly those working with ASP.NET, students learning C# programming, and anyone involved in creating web forms for data input and evaluation.

DemiAngel
Messages
1
Reaction score
0
Hi, I'm working on a students marks evaluation webpage, unfortunately i run into several problems and i need some help fixing it :smile:

Code:
<%@ Page Language="C#" %>
<script runat="server">

    void submit(object sender, System.EventArgs e)
    {
    lblMessage1.Text = TextBox1.Text;
    lblMessage2.Text = TextBox2.Text;
    lblMessage3.Text = DropListItem.SelectedItem.Text;
    }
    void Calculate(Object sender, System.EventArgs e)
    {
    int TotalGrade = Convert.ToInt32(TextBox3.Text) +
    Convert.ToInt32(TextBox4.Text) + Convert.ToInt32(TextBox5.Text);
    lblMessage4.Text = TotalGrade.ToString();
    }
    int Result
    {
    get { return Convert.ToInt32(lblMessage4.Text); }
     if (TotalGrade <= 100 || TotalGrade >= 90)
         lblMessage5.Text = "A, Excellent!";
     }
     else
     {
       if (TotalGrade <= 89 || TotalGrade >= 80)
         lblMessage5.Text = "B, Very Good!";
     }
     else
     {

        if (TotalGrade <= 79 || TotalGrade >= 70)
         lblMessage5.Text = "C, Good!";

     else
     {
        if (TotalGrade <= 69 || TotalGrade >= 60)
         lblMessage5.Text = "D, Not Bad!";

     else
     {
        if (TotalGrade <= 59 || TotalGrade >= 50)
         lblMessage5.Text = "E, Work Harder!";

     else
     {
        if (TotalGrade <= 49)
         lblMessage5.Text = "F, You Failed!";

</script>
<html>
<head>
    <title></title>
</head>
<body dir="ltr">
    <form runat="server">
        <p align="center">
        </p>
        <p align="center">
            <strong><font size="5"><u></u></font></strong>
        </p>
        <p align="center">
            <strong><font size="5"><u></u></font></strong>
        </p>
        <p align="center">
            <strong><font size="5"><u></u></font></strong>
        </p>
        <p align="center">
            <strong><font size="5"><u></u></font></strong>
        </p>
        <p align="center">
            <strong><font size="5"><u></u></font></strong>
        </p>
        <p align="center">
            <strong><font size="5"><u></u></font></strong>
        </p>
        <p align="center">
            <strong><font size="5"><u></u></font></strong>
        </p>
        <p align="center">
            <strong><font size="5"><u></u></font></strong>
        </p>
        <p align="center">
            <strong><font size="5"><u></u></font></strong>
        </p>
        <p align="center">
            <strong><font size="5"><u></u></font></strong>
        </p>
        <p align="center">
            <strong><font size="5"><u>Personal Information Form</u></font></strong>
        </p>
        <p align="center">
            <strong>Enter the Student Name :</strong>
        </p>
        <p align="center">
            <em><u>Student Name</u>:&nbsp;
            <asp:TextBox id="TextBox18" runat="server" Width="179px"></asp:TextBox>
            </em>
        </p>
        <p align="center">
            <strong>Enter the Student ID number :</strong>
        </p>
        <p align="center">
            <em><u>Student ID</u>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:TextBox id="TextBox19" runat="server" Width="179px"></asp:TextBox>
            </em>
        </p>
        <p align="center">
            <strong>Select Subject Code From the List:</strong>
        </p>
        <p align="center">
        </p>
        <p align="center">
            <asp:DropDownList id="DropDownList4" runat="server">
                <asp:ListItem>CIS 101</asp:ListItem>
                <asp:ListItem>CIS 102</asp:ListItem>
                <asp:ListItem>CIS 103</asp:ListItem>
                <asp:ListItem>CIS 110</asp:ListItem>
            </asp:DropDownList>
        </p>
        <p align="center">
            _________________________________
        </p>
        <p align="center">
            <font size="5"><strong><u>Student Grade Evaluation Form</u></strong></font>
        </p>
        <p align="center">
            <strong>Enter the Student Grades:</strong>&nbsp;
        </p>
        <p align="center">
            <em>First Grade:</em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:TextBox id="TextBox15" runat="server" Width="180px"></asp:TextBox>
        </p>
        <p align="center">
            <em>Second Grade:&nbsp;
            <asp:TextBox id="TextBox16" runat="server" Width="180px"></asp:TextBox>
            </em>
        </p>
        <p align="center">
            <em>Final Grade:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:TextBox id="TextBox17" runat="server" Width="180px"></asp:TextBox>
            </em>
        </p>
        <p align="center">
            <em>============================= </em>
        </p>
        <em></em><em>
        <p align="center">
            <asp:Button id="Button2" onclick="submit" runat="server" Width="287px" Text="Get Student Information Now"></asp:Button>
        </p>
        <p align="center">
            <asp:Button id="Button3" onclick="Calculate" runat="server" Width="286px" Text="Get the Total Grade Now"></asp:Button>
        </p>
        </em><em>
        <p align="center">
            Student Name: <asp:Label id="lblMessage1" runat="server"></asp:Label>
        </p>
        <p align="center">
            Student ID: <asp:Label id="lblMessage2" runat="server"></asp:Label>
        </p>
        <p align="center">
            Student Selected Subject: <asp:Label id="lblMessage3" runat="server"></asp:Label>
        </p>
        </em>
        <p align="center">
            <em>Total Grade: </em><asp:Label id="lblMessage4" runat="server" font-italic="True"></asp:Label><em></em>
        </p>
        <p align="center">
            <em></em>
        </p>
        <p align="center">
            <em>&nbsp;Evaluation Letter:&nbsp;</em><asp:Label id="lblMessage5" runat="server" font-italic="True"></asp:Label><em></em>
        </p>
    </form>
</body>
</html>

Mainly i can't fix the #line error that i always get and i can't make the if-else statements to work :mad:

Please help me out & thanks,
 
Technology news on Phys.org
Since this looks like homework I would suggest you look up the difference between the boolean operators || and &&.

You might also think about how you can eliminate the need for the boolean operator altogether.

Last but not least you might want to check the syntax on "else if"
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 6 ·
Replies
6
Views
5K