Link to home
Start Free TrialLog in
Avatar of Sukesh Shukla
Sukesh Shukla

asked on

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

User generated imageAnd 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
Avatar of kaufmed
kaufmed
Flag of United States of America image

Check that Session["UserName"] is not null prior to calling ToString against it.
ASKER CERTIFIED SOLUTION
Avatar of John Gates, CISSP, CDPSE
John Gates, CISSP, CDPSE
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of OriNetworks
OriNetworks

This can happen if session state times out.
CAn you post the codebehind for the function??
So exactly what I said?