Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

Answers were Sorted based on User's Feedback



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

Answer / badrinath

using querystring

Is This Answer Correct ?    13 Yes 0 No

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

Answer / rok_here

Through Requested.querystring we can send the value from
one page to another Page

Is This Answer Correct ?    4 Yes 0 No

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

Answer / 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

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

Answer / arif khan

Create Default.aspx

this is my Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//
EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Welcome to Default page1</h1>
<asp:TextBox ID="txt1" runat="server" />
<asp:Button ID="btn" runat="server" Text="Submit"
OnClick="Transfer_Click" />
</div>
</form>
</body>
</html>

Code file
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

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

}
protected void Transfer_Click(object sender, EventArgs
e)
{
Server.Transfer("~/Default2.aspx");
}
}


create Default2.aspx

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//
EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Welcome to Default page 2</h1>
<asp:Label ID="lblshow" runat="server"></asp:Label>
</div>
</form>
</body>
</html>

code file

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox txt = (TextBox)Page.PreviousPage.FindControl
("txt1");
lblshow.Text = txt.Text;
}
}

Is This Answer Correct ?    3 Yes 1 No

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

Answer / kinjal

in first page write

textbox1.text="k";
string str=textbox1.text.trim();
respons.redirect("page2.aspx?id="+str);

Is This Answer Correct ?    2 Yes 2 No

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

Answer / mercy

cookies provide to store information in web applications.
you can add cookies like
Response.Cookies("userName").Value = "mercy"

Is This Answer Correct ?    0 Yes 1 No

Post New Answer



More Dot Net General Interview Questions

Can we use data reader to bind gridview?

3 Answers   TCS,


How does cas works?

0 Answers  


What are the providers available with VS.NET ?

2 Answers   TCS,


Name for built-in permission sets in .Net

1 Answers  


What is meant by globalization?

0 Answers  






Explain is the jit an interpreter?

0 Answers  


What is the native image generator?

0 Answers  


Which property is used in the email to send the content as HTML

1 Answers  


Why DLL files are needed. & how They are Created in DOTNET?

1 Answers  


Explain the process of serialization in .NET?

0 Answers  


What are multicast delegates?

0 Answers  


If you are executing these statements in commandobject. Select * from table1; select * from table2? How you will deal result set? 42. How do you sort a dataset.

0 Answers  






Categories