Search This Blog

Saturday, 21 November 2015

ASP.NET server controls and that uses ViewState internally.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {       
        protected void Page_Load(object sender, EventArgs e)
        {
           if(!IsPostBack)
           {
               TextBox1.Text = "0";
           }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int ClicksCount = Convert.ToInt32(TextBox1.Text) + 1;
            TextBox1.Text = ClicksCount.ToString();
        }
    }
}


Note:

Asp tools all are server side control so if click the event button the value will be transfer to the server side and return the value to the page.
HTML is the client side control so it will not transfer to the server. after the click event the value will be destroyed. 



No comments:

Post a Comment