Problem in solving this Error"Object reference not set to an instance of an object."

I have One User Panel Which has various functions....But when I click on change Password option I get the following error

The ErrorAnd My User Panel is:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="User_Panel.aspx.cs" Inherits="housing1.User_Panel" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">

        .auto-style1 {
            text-align: center;
        }
        .auto-style2 {
            font-size: x-large;
            font-weight: bold;
            text-decoration: underline;
        }
        .auto-style3 {
            font-size: x-large;
            font-weight: bold;
        }
    </style>
</head>
<body style="background-color: #CCFFFF">
    <form id="form2" runat="server">
         <div class="auto-style1">
             <span class="auto-style2">User Panel</span><br class="auto-style3" />
             <br />
             <br />
             </div>
    <div style="text-align: center">
   
        <asp:LinkButton ID="LinkButton1" runat="server" BackColor="#FFCC99" BorderColor="Black" BorderStyle="Double" CausesValidation="False" Height="30px" PostBackUrl="~/Users/add_fmember.aspx" Width="152px">Add Family Details</asp:LinkButton>
        <br />
        <br />
        <asp:LinkButton ID="LinkButton2" runat="server" BackColor="#FFCC99" BorderColor="Black" BorderStyle="Double" CausesValidation="False" Height="30px" PostBackUrl="~/Users/edit_member.aspx" Width="152px">Update Details</asp:LinkButton>
        <br />
        <br />
        <asp:LinkButton ID="LinkButton3" runat="server" BackColor="#FFCC99" BorderColor="Black" BorderStyle="Double" CausesValidation="False" Height="30px" PostBackUrl="~/Users/Ucomplain.aspx" Width="152px">Generate Complain</asp:LinkButton>
        <br />
        <br />
        <asp:LinkButton ID="LinkButton6" runat="server" BackColor="#FFCC99" BorderColor="Black" BorderStyle="Double" CausesValidation="False" Height="30px" PostBackUrl="~/Users/My_Complain.aspx" Width="152px">Update Complains</asp:LinkButton>
        <br />
        <br />
        <asp:LinkButton ID="LinkButton4" runat="server" BackColor="#FFCC99" BorderColor="Black" BorderStyle="Double" CausesValidation="False" Height="39px" PostBackUrl="~/Users/Check_Status.aspx" Width="152px">Check Status</asp:LinkButton>
    
        <br />
        <br />
        <asp:LinkButton ID="LinkButton5" runat="server" BackColor="#FFCC99" BorderColor="Black" BorderStyle="Double" CausesValidation="False" Height="39px" Width="152px" OnClick="LinkButton5_Click">Change Password</asp:LinkButton>
    
    </div>
         <asp:HiddenField ID="HiddenFieldUN" runat="server" />
         <br />
         <p>
             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Index/Index.aspx" />
             &nbsp;</p>
    </form>
    
</body>
</html>

Open in new window


The Page where the error appears is User_Panel.aspx , when I return back after performing some other functionality for ex I clicked update details and then I come back to user panel and click change password so i get this error mentioned above......
User_Panel.aspx.cs
Sukesh ShuklaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Check that Session["UserName"] is not null prior to calling ToString against it.
John Gates, CISSPSecurity ProfessionalCommented:
You can check this like:

HiddenfieldUN.value =  Session["UserName"]  == null ? "" : Session["UserName"].ToString();


That is if you are ok with that value = ""

Hope this helps!
-D-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OriNetworksCommented:
This can happen if session state times out.
John Gates, CISSPSecurity ProfessionalCommented:
CAn you post the codebehind for the function??
käµfm³d 👽Commented:
So exactly what I said?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.