Click here to Skip to main content
15,902,853 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to access a control of contextplace holder of masterpage on the code behind file of masterpage.

I did it by creating property but it gives me a error of stackoverflow.
controls are buttons

C#
public Button seeProfole
      {
          get { return seeProfole; }
          set { seeProfole = value; }
      }



its use :
C#
seeProfole.Visible = true;


plz help

What I have tried:

I am trying to access a control of contextplace holder of masterpage on the code behind file of masterpage.

I did it by creating property but it gives me a error of stackoverflow.
controls are buttons

public Button seeProfole
{
get { return seeProfole; }
set { seeProfole = value; }
}

plz help
Posted
Updated 14-Apr-16 10:07am
v2

Are you surprised by the StackOverflowException? Your property accessor calls the property accessor, which calls the property accessor, which calls the ....

Your property accessor needs to return the control, not the property. If the property name is the same as the control ID, then you'll need to change one. Remember, C# is case-sensitive, so you could simply change the case:
C#
public Button SeeProfole
{
    get { return seeProfole; }
    set { seeProfole = value; }
}
 
Share this answer
 
Comments
Kishor-KW 14-Apr-16 15:13pm    
on following line it give error thar seeProfole does not exist which is my control name
return seeProfole
Richard Deeming 14-Apr-16 15:15pm    
Well, if it's telling you that seeProfole doesn't exist, then it's either not the ID of your control, or the control is nested inside a data-bound control, and doesn't have a field in the code-behind.
Kishor-KW 14-Apr-16 15:17pm    
i change codefile by codebehind and it is my control name
Richard Deeming 14-Apr-16 15:18pm    
Well it's clearly NOT your control's ID; if it was, you wouldn't be getting that error!
Kishor-KW 14-Apr-16 15:20pm    
but it is not in contextplaceholder. now i take it outside of it.
Button seepro = (Button)Master.FindControl("seeProfole");

work for me
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 14-Apr-16 19:48pm    
Very, very bad. It has nothing to do with your problem, which is perfectly explained in Solution 1. If you won't follow it, nothing will work.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900