ASP.net webpage troubleshooting required

In summary, The conversation is about working on a student's marks evaluation webpage and encountering problems with the code. The person is seeking help in fixing the #line error and making the if-else statements work. Suggestions are given to look up the difference between boolean operators and consider eliminating the need for them, as well as checking the syntax on "else if" statements.
  • #1
DemiAngel
1
0
Hi, I'm working on a students marks evaluation webpage, unfortunatly 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
  • #2
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"
 
  • #3


Hi there,

Thank you for reaching out for help with your ASP.net webpage troubleshooting. I understand that you are working on a students marks evaluation webpage and have run into some problems. Let's take a look at the code and see if we can identify the issues and find a solution.

Firstly, the #line error you are getting is most likely due to a missing or incorrect line number in your code. Please double check all your code and make sure that the line numbers match up with the error message.

As for the if-else statements not working, I noticed that there are a few errors in the code. Firstly, the "Result" function should be outside of the "Calculate" function and should not have a "void" return type. It should also have a closing bracket at the end. Furthermore, the if-else statements should be properly nested, with each "if" statement having its own closing bracket. Here is an example of how it should look:

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!";
}
}

I hope this helps resolve your issues. If you continue to have trouble, I suggest breaking down the code and testing each section separately to identify where the problem lies. Also, don't forget to check for any missing brackets or syntax errors.

Best of luck with your project!
 

1. What is ASP.net?

ASP.net is a web application framework developed by Microsoft for creating dynamic and interactive websites, web applications, and web services. It is built on the Common Language Runtime (CLR) and allows developers to use different programming languages such as C#, VB.net, and F# to build web applications.

2. Why is troubleshooting required for ASP.net webpages?

Troubleshooting is required for ASP.net webpages to identify and fix any issues or errors that may occur during the development or deployment process. This ensures that the webpage functions properly and provides a good user experience.

3. What are some common issues that may require troubleshooting for ASP.net webpages?

Some common issues that may require troubleshooting for ASP.net webpages include coding errors, configuration problems, compatibility issues with browsers or servers, and database connectivity issues.

4. How can I troubleshoot ASP.net webpages?

To troubleshoot ASP.net webpages, you can use debugging tools such as Visual Studio, check error logs, review the source code, and use online resources and forums for help. It is also important to follow best practices and regularly test the webpage during development.

5. What are some tips for effective ASP.net webpage troubleshooting?

Some tips for effective ASP.net webpage troubleshooting include breaking down the problem into smaller parts, testing and debugging one component at a time, using proper error handling and logging techniques, and seeking help from experienced developers or online communities if needed.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
222
Replies
9
Views
3K
Back
Top