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 6771105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:23:33+00:00 2026-05-26T15:23:33+00:00

Property in UserControl: public JobQuote quote { get { if (ViewState[Quote] != null) return

  • 0

Property in UserControl:

     public JobQuote quote
{
    get 
    {
        if (ViewState["Quote"] != null)
            return (JobQuote)ViewState["Quote"];
        else
        {
            JobQuote newQuote = new JobQuote();
            return newQuote;
        }   
    }
    set { ViewState["Quote"] = value; }
}

Code being run in UserControl:

protected void button_UploadFile_Click(object sender, EventArgs e)
{
    if (FileUploader.HasFile)
    {
        try
        {
            quote.JobFileNames.Add(System.IO.Path.GetFileName(FileUploader.FileName));
        }
        catch (Exception ex)
        {
            label_UploadStatus.Text = "Upload status: The file could not be uploaded.  <br />The following error occurred: " + ex.Message;
        }
    }
}

Property from JobQuote.cs class:

public List<string> JobFileNames
{
    get 
    {
            return JobFileNames;
    }
    set { JobFileNames = value; }
}

The exception is being thrown in the Try block when the code tries to access the JobFileNames property of the JobQuote class.

  • 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-26T15:23:34+00:00Added an answer on May 26, 2026 at 3:23 pm

    The getter and setter of the JobFileNames property are referencing themselves, causing an infinite loop. When that loop exhausts the available stack space you get a StackOverflowException.

    You probably need some sort of backing field for the property. Either explicit…

    private List<string> _jobFileNames;
    public List<string> JobFileNames
    {
        get { return _jobFileNames; }
        set { _jobFileNames = value; }
    }
    

    …or, better still, auto-implemented…

    public List<string> JobFileNames { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code for Property in JobQuote class: public class JobQuote { // Properties private List<string>
Trying to get the value of a property on a usercontrol displayed on a
I have a UserControl in my Asp.net project that has a public property. I
Is it possible to set the DataContext property of a usercontrol after the user
I have a UserControl, with a TextBox and a databound property - Value. Value
simple question regarding property value inheritance in UserControls. If i create a UserControl, it
I want to loop through the controls on a UserControl and set a property
Consider this abstract class public abstract class Foo { public Injectable Prop {get;set;} }
I like to create a UserControl with own Header Property. public partial class SomeClass:
I have a UserControl with a DependencyProperty. I set it's value in the host

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.