Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / June 2004

Tip: Looking for answers? Try searching our database.

Unable to access a control property - Stack Overflow..

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nelson F. - 29 Jun 2004 20:05 GMT
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!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.