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?
Iain - 29 Jun 2004 21:46 GMT
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
> 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
[quoted text clipped - 20 lines]
>
> Am I doing something wrong?
Nelson F. - 29 Jun 2004 22:36 GMT
> would work admirably.
It did.
First let me say a heartfelt THANK YOU!
Second let me say a humble and humilating D'OH!