Reputation: 13
I have textbox inside a user control(ascx page) like this :
<asp:TextBox ID="textbox1" runat="server" PlaceHolder="Practice Name"></asp:TextBox>
Now when I try to access this textbox from code behind, it is not getting initialized and shows as null.
textbox1.text = "ABC";
The above statement should assign textbox1's text as "ABC" but it is showing as null and gives an error object reference not set to an instance of an object.
Please help!
Upvotes: 0
Views: 469
Reputation: 5078
Make sure your user control is registered on the aspx page that's using it. At the top should be something like
<%@ Register Src="~/Controls/MyCtrl.ascx" TagName="MyCtrl" TagPrefix="xyz" %>
Upvotes: 1
Reputation: 1
try to create another textbox drag and drop .. Place holder could make some issue in implementing asp controls.
Upvotes: 0