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

  • Home
  • SEARCH
  • 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 1087389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:55:59+00:00 2026-05-16T22:55:59+00:00

The error I get is :The name agentName does not exist in the current

  • 0

The error I get is :The name agentName does not exist in the current context”

On default.aspx I have <asp:TextBox ID="agentName" runat="server" />

On code behind file I have agentName.Text

But is says the above error message.

when I pass hard coded value like “John”, it works. I need a way to recognize the textbox on code-behind.

Thanks

Following is my code:

Default.aspx:

//code behind on @page directive
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="WebApplication2.WebForm1"%>

// Getting the value from XML
 Agentname.Text = root.SelectSingleNode("name").ChildNodes[0].Value; 

// Assigned a textbox
asp:TextBox ID="Agentname" runat="server" disabled="true" MaxLength="57" /
(removed angel bracket as SO is ignoring this line, don't know why)

//Code behind

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WebApplication2
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        public void SaveXml(object sender, EventArgs e)
        {
            XDocument xmlDoc = XDocument.Load(Server.MapPath("Agent.xml"));
            Console.WriteLine("read XML");
            var person = xmlDoc.Descendants("agent");
            person.ElementAt(0).Value = "";

            xmlDoc.Element("agent").Add(new XElement("name", Agentname.Text));

            xmlDoc.Save(Server.MapPath("Agent.xml"));



        }
    }
}
  • 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-05-16T22:55:59+00:00Added an answer on May 16, 2026 at 10:55 pm

    Sometimes the designer file gets out of sync with the aspx file. Delete the “YourPage.aspx.designer.cs” file, then right click the form in the solution explorer and select something like “Covert to Web Application”

    This will regenerate the designer to match the current aspx.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get a few errors saying: The name 'title' does not exist in it's
i am trying to use session but i get error: The name 'Session' does
i get this error when trying this: ERROR method name expected. How should i
Django's get_or_create function always cause get() returned more than one Model name error in
If I do this stuff.addEventListener(FooEvent.NAME, function(e:FooEvent) { dispatchEvent(e); } I get a runtime error
Consider: class Foo { public string Name{get;set;} public string[] WebSites{get;set;} } I have a
I have the following code files: public interface IMod { string Name { get;
Hey I have a name column in my table, suppose i get have name
$ rake spec 1) GroupsController GET show show one group's name & description Failure/Error:
I'm trying to do ALTER table tbl_name Engine=MyISAM; and I get ERROR 1217 (23000):

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.