Groups | Blog | Home
all groups > asp.net building controls > june 2004 >

asp.net building controls : Unable to access a control property - Stack Overflow..


Nelson F.
6/29/2004 12:05:10 PM
I've made a user control (ascx and ascx.cs) that works fine if I use a
session var to pass it value. However, I'd much prefer to set a property
instead so I added a property. The problem is that when I try to access the
property, it generates a StackOverflowException. See the snip from my source

---<snip>----

public string SelectedTab
{
get{ return SelectedTab; }
set{ SelectedTab = value; }
}

private void Page_Load(object sender, System.EventArgs e)
{
if (SelectedTab != null) // Stack exception here.
{
//....do something
}
}

---<snip>---

Am I doing something wrong?

Nelson F.
6/29/2004 2:36:04 PM
[quoted text, click to view]

It did.

First let me say a heartfelt THANK YOU!

Second let me say a humble and humilating D'OH!


Iain
6/29/2004 9:46:19 PM
You are returning a SelectedTab.

SelectedTab is a property which returns SelectedTab.

Hence you have infinite recursion.

private String mSelectedTab;

public string SelectedTab
{
get{ return mSelectedTab; }
set{ mSelectedTab = value; }
}

would work admirably.

Iain
[quoted text, click to view]

AddThis Social Bookmark Button