session code2

DESIGN:
create session
name-t1.text
city-t2.text
m1-t3.text
m2-t4.text
m3-t5.text
total-t6.text
color-t7.text
     button

on button click
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int a, b, c;
        Session["name"] = TextBox1.Text;
        Session["city"] = TextBox2.Text;
        Session["m1"] = TextBox3.Text;
        Session["m2"] = TextBox4.Text;
        Session["m3"] = TextBox5.Text;
        Session["total"] = TextBox6.Text;
        Session["color"] = TextBox7.Text;

     
     //   TextBox6.Text = c.ToString();

        Response.Redirect("form.aspx");

    }
    protected void TextBox6_TextChanged(object sender, EventArgs e)
    {

       
       
            }
    protected void TextBox5_TextChanged(object sender, EventArgs e)
    {
        int a, b, c, d;
        a = int.Parse(TextBox3.Text);
        b = int.Parse(TextBox4.Text);
        c = int.Parse(TextBox5.Text);
        d = a + b + c;
        TextBox6.Text = d.ToString();

 // text6.text make postbackURL as TRUE 
    }

}


 Calling Session

name-l1.text
city-l2.text
m1-l3.text
m2-l4.text
m3-l5.text
total-l6.text
color-l7.text

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

public partial class form : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = (string)Session["name"];
        Label1.BackColor = System.Drawing.Color.FromName((string)Session["color"]);
        Label2.Text=(string)Session["city"];
        Label2.BackColor= System.Drawing.Color.FromName((string)Session["color"]);
        Label3.Text=(string)Session["m1"];
        Label3.BackColor = System.Drawing.Color.FromName((string)Session["color"]);
        Label4.Text=(string)Session["m2"];
        Label4.BackColor = System.Drawing.Color.FromName((string)Session["color"]);
        Label5.Text=(string)Session["m3"];
        Label5.BackColor = System.Drawing.Color.FromName((string)Session["color"]);
        Label6.Text=(string)Session["total"];
        Label6.BackColor = System.Drawing.Color.FromName((string)Session["color"]);

    }

}

Popular Posts