Jump to content
Xtreme .Net Talk

User controls causing a StackOverflowException in visual studio [c#]


Recommended Posts

Posted

Here's the situation...

 

I have web user control (.ascx) that has some properties I would like to define when the user control is added to the form. Currently I am under the impression that the code (c#) in the user control should be:

 

public string name

{

get

{

return name;

}

set

{

name = value;

}

}

 

and then in the web form's asp.net code I set the name when I declare the user control:

 

<uc1:WebUserControl1 id="WebUserControl11" name="testing" runat="server"></uc1:WebUserControl1>

 

If I don't declare the name there then it all works fine (except I have an unnamed control)

 

Can anyone see what I'm doing wrong?

Posted

Ok, so to answer my own question for the benifit of anyone else who may want to know, the c# code needed to be:

 

private string _name = "";

public string name

{

get

{

return _name;

}

set

{

_name = value;

}

}

 

and then assign a value by going:

 

_name = this.name;

 

Problem solved (2.5 hours...but solved none the less).

 

Now, how can I...hmmmmmmmmmmmm

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...