TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohit Kapoor
1.6k
94
19.9k
Session variable and Application variable
Jul 15 2016 4:37 PM
Why value of Session variable and Application variable updates on page reload !!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace part_5_WebApplication2
{
public partial class Session1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["Click"] == null)
{
Session["Click"] = 0;
}
TextBox1.Text = Session["Click"].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
int click_count = (int)Session["Click"] + 1;
TextBox1.Text = click_count.ToString();
Session["Click"] = click_count;
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
------------------------------------------------------------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Session1.aspx.cs" Inherits="part_5_WebApplication2.Session1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Click me !" />
</div>
</form>
</body>
</html>
Attachment:
upload.zip
Reply
Answers (
3
)
import data to xls file and show data grid & store data mvc4
how to remove data that bind inside repeater in c#