Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

       txtUsername.Focus()
       Me.Master.FindControl("NavigationMenu").Visible = False
       Me.Master.FindControl("btnsignup").Visible = True
       Me.Master.FindControl("btnlogout").Visible = False
       
       Me.Master.FindControl("Label2").Visible = False
       Me.Master.FindControl("lblloginuser").Visible = False

   End Sub





these all are worked fine but when i'm apply this on div then error
Object reference not set to an instance of an object.

Me.Master.FindControl("divwelcome").Visible = False

what me should to do
plz help

thanks
Posted

we should use runat="server" in div
 
Share this answer
 
Hello Neeraj,

Try this
In the page load event of this page add the following code
VB
Dim navDiv As HtmlContainerControl = DirectCast(Me.Master.FindControl("divwelcome"), HtmlContainerControl)
navDiv.Visible = False


Or

check the aspx for id and runat= "server"

<div id="divwelcome" runat="server">

All the best:) pls write back for support.
 
Share this answer
 
v2
Comments
neeraj_ 19-Apr-14 2:33am    
same error sir
karthik Udhayakumar 19-Apr-14 2:45am    
did u name your div ?
Can you pls check whether you have passed the <div id="divwelcome" runat="server"> in the aspx
karthik Udhayakumar 19-Apr-14 3:16am    
Hello Neeraj,
Dont use solution area for comments:)

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