Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7825633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:05:26+00:00 2026-06-02T09:05:26+00:00

I am looking for a wise wizard to point me in the right direction.

  • 0

I am looking for a wise wizard to point me in the right direction. I am making a mock comic database using XML and C#. Everything works splendidly except for my edit page. On my localhost I get an Object Reference error, on my host I get a runtime error.

The live page is here: (login username is Administrator and password is adminpass!)
http://www.lmabee.com/test/XMLProject/Admin/comicsEdit.aspx?id=2

My code is as follows:

comicsEdit.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/adminMaster.master" AutoEventWireup="true" CodeFile="comicsEdit.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content2" ContentPlaceHolderID="center" Runat="Server">
<asp:Label ID="lblOutput" runat="server"  Visible="true" />
<asp:Panel ID="pnlEdit" runat="server" Visible="false">
    <h1>
        Edit Comic Database
    </h1>

    <div id="divMessage">
    <asp:Label ID="lblMessage" runat="server"></asp:Label></div>
    <table>
        <tr>
            <td >
                <asp:Label ID="lblTitle" runat="server" Text="Label">Title:</asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtTitle" runat="server" Width="200px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="val1" runat="server" ErrorMessage="Please enter a title"
                    Display="Dynamic" ControlToValidate="txtTitle"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td >
                <asp:Label ID="lblIssue" runat="server" Text="Label">Issue:</asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtIssue" runat="server" Width="200px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please enter a Issue"
                    Display="Dynamic" ControlToValidate="txtIssue"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td >
                <asp:Label ID="lblDesc" runat="server" Text="Label">Description:</asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtDesc" runat="server"  Width="200px" Height="200px" TextMode="MultiLine"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Please enter a Description"
                    Display="Dynamic" ControlToValidate="txtDesc"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td  colspan="2">
                <asp:Button ID="btnEdit" OnClick="btnEdit_Click" runat="server" Text="Update Comic">
                </asp:Button>
            </td>
        </tr>
    </table>
</asp:Panel>
</asp:Content>

And my codebehind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;

public partial class _Default : System.Web.UI.Page
{
int intComicID;
XmlDocument myXmlDocument = new XmlDocument();
XmlNode rootNode;
XmlNode GrabComic;

public void Page_Load(object Src, EventArgs E)
{
    if (!Page.IsPostBack)
    {

        intComicID = Convert.ToInt32(Request.QueryString["id"]);

        if (intComicID == null || intComicID.ToString() == "0")
        {// doesn't include id parameter 
            lblOutput.Visible = true;
            lblOutput.Text = "no item selected.";
        }

        else
        {// id has value
            myXmlDocument.Load(Request.PhysicalApplicationPath + @"comic.xml");
            XmlNode rootNode = myXmlDocument.DocumentElement;
            GrabComic = rootNode.ChildNodes[intComicID - 1];

            if (GrabComic == null)
            {// invalid id
                lblOutput.Visible = true;
                lblOutput.Text = "item doesn't exist.";
            }
            else
            {// valid id
                pnlEdit.Visible = true;
                txtTitle.Text = GrabComic.ChildNodes[0].InnerText;
                txtIssue.Text = GrabComic.ChildNodes[1].InnerText;
                txtDesc.Text = GrabComic.ChildNodes[2].InnerText;
            }
        }
    }

}

public void btnEdit_Click(object sender, EventArgs e)
{
    GrabComic.ChildNodes[0].InnerText = txtTitle.Text;
    GrabComic.ChildNodes[1].InnerText = txtIssue.Text;
    GrabComic.ChildNodes[2].InnerText = txtDesc.Text;

    myXmlDocument.Save(Request.PhysicalApplicationPath + @"comic.xml");

    lblMessage.Text = "You have successfully updated the Database";
}
}

I was so fed up, I literally started from scratch on this file 6 times now. Would anyone be willing to shed some light on this issue for this sad sap?
I would truly, truly be grateful. I’m currently working on 3 hours sleep for the last 48, so I honestly would kiss your feet.

Best!
Laura

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:05:29+00:00Added an answer on June 2, 2026 at 9:05 am

    Problem may be myXmlDocument not loaded when you call btnEdit_Click

    string file = Path.Combine(Request.PhysicalApplicationPath, "comic.xml");
    if(File.Exists(file))
    {
        myXmlDocument.Load(file);
        XmlNode rootNode = myXmlDocument.DocumentElement;
        if(rootNode !=null && rootNode.ChildNodes.Count> intComicID)
        {
           GrabComic = rootNode.ChildNodes[intComicID - 1];
                if (GrabComic == null)
                {// invalid id
                    lblOutput.Visible = true;
                    lblOutput.Text = "item doesn't exist.";
                }
                else
                {// valid id
                    pnlEdit.Visible = true;
                    txtTitle.Text = GrabComic.ChildNodes[0].InnerText;
                    txtIssue.Text = GrabComic.ChildNodes[1].InnerText;
                    txtDesc.Text = GrabComic.ChildNodes[2].InnerText;
                }
        }
    
    }
    

    in your btnEdit_Click method

    public void btnEdit_Click(object sender, EventArgs e)
    {
        if(myXmlDocument != null && GrabComic != null && GrabComic.ChildNodes.Count >3){
    
            GrabComic.ChildNodes[0].InnerText = txtTitle.Text; 
            GrabComic.ChildNodes[1].InnerText = txtIssue.Text;
            GrabComic.ChildNodes[2].InnerText = txtDesc.Text;
            myXmlDocument.Save(Path.Combine(Request.PhysicalApplicationPath, "comic.xml"));
    
            lblMessage.Text = "You have successfully updated the Database";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking into using either of mentioned ways of dealing with long running
I have not used PackedArray before, but just started looking at using them from
Short: I am looking for a very simple (configuration/maintenance wise) solution, that would allow
I'm a non-developer building a simple Access 2003 database for an NGO that works
I'm using a UIProgressView in my application, which is working great right now. But
I am looking for a solution using a 1-stmt LINQ query instead. I have
I'm looking to recreate apple's cover flow effect using jQuery. I've looked at some
I'm looking for ways of converting an array of byte values in DWord using
Looking for a good set of base objects to start a website up in
Looking to move data from a table A to history table B every X

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.