Click here to Skip to main content
15,910,878 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Im disable a button on pageload. and my program does all the activities and it should enable the button . but the button is disabled back as the page reloads. so i want to count the page load and put a condition like if the count( page load) is more than one then dont disable it . how do i do that? can i get the code please. i tried it nothing worked
Posted
Comments
DaveAuld 2-Dec-11 11:33am    
Not sure exactly what you are doing, but have you looked at 'isPostBack'?

Just put Your Code in

If Not pageIsPostBack then


Your Code...


ENdIf
 
Share this answer
 
C#
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Application["visits"] == null)
                {
                    Application["visits"] = 1;
                }
                else
                {
                    int visits = (int)Application["visits"];
                    visits++;
                    Application["visits"]=visits;
                    if (visits > 1)
                    {
                        myButton.Enabled = true;
                    }
                }
            }

        }
 
Share this answer
 
v2

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