Click here to Skip to main content
13,768,408 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
below code i have to write in 2 or three lines how can i write this can any one help plzzzz..........


this is my first page....

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            Response.Write("you have sucessfully registred...!!!");
        }
    }

    protected void btnsubmit_Click1(object sender, EventArgs e)
    {
        Application["DEMO_APPLICATION"] = txtname.Text;
        Application["DEMO_APPLICATION1"] = txtpwd.Text;
        Application["DEMO_APPLICATION2"] = txtpassword.Text;
        Application["DEMO_APPLICATION3"] = txtadd.Text;
        Application["DEMO_APPLICATION4"] = txtfull.Text;
        Application["DEMO_APPLICATION5"] = DropDownList1.SelectedIndex;
        Response.Redirect("default3.aspx");


    }
  }


this is my second page:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        TextBox1.Text =Application["DEMO_APPLICATION"].ToString();
        TextBox2.Text = Application["DEMO_APPLICATION1"].ToString();
        TextBox3.Text = Application["DEMO_APPLICATION2"].ToString();
        TextBox4.Text = Application["DEMO_APPLICATION3"].ToString();
        TextBox5.Text = Application["DEMO_APPLICATION4"].ToString();
        TextBox6.Text = Application["DEMO_APPLICATION5"].ToString();
    }
}
Posted 19-Feb-12 19:45pm
Updated 19-Feb-12 19:50pm
v3
Comments
Varun Sareen 20-Feb-12 0:52am
   
why?
rockpune 20-Feb-12 0:56am
   
i have to learn how to write above code in 2 or 3 lines plzzz tell me sir
BillWoodruff 20-Feb-12 0:52am
   
homework ?
rockpune 20-Feb-12 0:57am
   
i have to learn how to write above code in 2 or 3 lines plzzz tell me sir

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,

You do not need to store Textbox value in Application variable.

PreviousPage.FindControl could be used to minimize code on Default2 page.

Required code on Default3 page.

TextBox1.Text = ((TextBox) PreviousPage.FindControl("txtname")).Text;


but again in above code you need checking for txtname existance. So, its not always possible to minimize number of lines. but the important thing is the correct behavior then optimization.

Hope this will help you.

Thanks
-Amit.
  Permalink  
Comments
Technoses 20-Feb-12 3:11am
   
good work
@AmitGajjar 20-Feb-12 3:42am
   
Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04-2016 | 2.8.181116.1 | Last Updated 20 Feb 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100