Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Declared a boolean variable In a Aspx Page Which is having master Page as :
public static Boolean gbooAddNewFlag



C#
public override string fnCreateMe()
   {
       try
       {
         gbooAddNewFlag = true;
       }
}
        catch (Exception ex)
        {
            OrbitMt.sbShowError(ex.Message.ToString());
            return ex.Message.ToString();
        }
    }



The value will set to null after postback...

Pls Help.
Posted
Updated 15-Mar-12 2:02am
v2
Comments
Nilesh Patil Kolhapur 15-Mar-12 8:04am    
boss it happens because of http is state less protocol k done state management for this

Instead of using a static variable, use the Session object:

C#
Session("gbooAddNewFlag") = true;

if ((bool)(Session("gbooAddNewFlag")))
{
    //do something...
}
 
Share this answer
 
v2
Comments
Ajith The Great 15-Mar-12 8:15am    
I am not interested in Using Session ...
Is there any other way out..
#realJSOP 15-Mar-12 8:38am    
Why not, that's EXACTLY what Session is for - retaining data between page refreshes. You're wasting time fighting accepted practice. Use Session, and get on with your tasking.
Hi,

you need to store this information anywhere either in ViewState,Cookies,Session,HiddenField. otherwise you class object will be destroy after postback and information will be lost.

Thanks
-Amit
 
Share this answer
 

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