Reputation: 1654
I have added placeholder to a page as below.
<tr >
<td >
<asp:PlaceHolder ID="phMemberName" runat="server" >
</asp:PlaceHolder>
</td>
<td>
<asp:PlaceHolder ID="phMemberTextboxes" runat="server">
</asp:PlaceHolder>
</td>
</tr>
I am adding controls(checkboxes) to it dynamically to it. It works fine but it throws an error if run in debug mode. What is the reason ?
The error is
The name 'phMemberName' does not exist in the current context
Upvotes: 0
Views: 2650
Reputation: 121
You might be missing the aspx.designer.cs file. Since this file essentially glues the aspx markup controls to the CodeBehind page(aspx.cs), absence of this file can cause the CodeBehind page to not understand where the "placeholderName" placeholder control exists and hence the error "does not exist in current context".
Upvotes: 0
Reputation: 1654
The problem can be solved the issue using FindControl() like ,
PlaceHolder phMName = (PlaceHolder)form1.FindControl("ControlID");
Upvotes: 1
Reputation: 3098
Is it possible you've made a typo? "The name 'placeholderName' does not exist in the current context" Should that not be "phMemberName"
Upvotes: 0