Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How do you pass value of a text box from page1.aspx to
page2.aspx without storing it as a session value?

Answer Posted / rishiraj r

We can also use cross post back property ofASP.NET 2.0

eg:

1. Specify the ListBox as

<asp:ListBox ID="ListBox1" runat="server" >
<asp:ListItem Value="1" Text="1st Option" />
<asp:ListItem Value="2" Text="2nd Option" />
<asp:ListItem Value="3" Text="3rd Option" />
</asp:ListBox>

2. Add this code in the default.aspx(.cs)

public ListBox TheListBox
{
get
{
return ListBox1;
}
}
protected void Page_Load(object sender, EventArgs e)
{
//Generate the cross-page postback script
PostBackOptions options = new PostBackOptions
(ListBox1);
//This will trigger correct script generation
options.ActionUrl = "secondPage.aspx";

//Add it to onchange attribute if the ListBox
string s =
Page.ClientScript.GetPostBackEventReference(options);
ListBox1.Attributes["onchange"]=s;

}

3. Then on secondPage.aspx

3.1 In aspx

<%@ PreviousPageType VirtualPath="~/Default.aspx" %>

3.2 in Page_Load of the secondPage.aspx(.cs)

protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null &&
PreviousPage.IsCrossPagePostBack)
{
Response.Write("You selected " +
PreviousPage.TheListBox.SelectedValue );
}
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What data providers available in .net to connect to database?

922


What is misl?

1000


Explain the difference between the stack and the heap?

919


Do you know what is the difference between an abstract class and an interface?

960


which methos do you invoke on the dataadapter control to load your generated dataset with data?

1001


Which namespace is used to support multithearding in .NET?

946


What are an object and a class?

1027


How to create properties and methods using controls?

1060


Explain what do the terms “boxing” and “unboxing” mean?

951


Write the .net syntax for 'for loop'?

971


What's the .net collection class that allows an element to be accessed using a unique key?

971


Explain .net framework overview?

1013


Do you know what's the difference between .net and laravel?

1053


How will you load dynamic assembly? How will create assemblies at run time?

2081


Explain can the validation be done in the server side? Or this can be done only in the client side?

887