Click here to Skip to main content
15,167,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hai all,

In my scenario am using java-script popup that popups another form which is an address entry form of merely 20 Controls in it.

Now I retrieving data from address page to main page by using a session variable which stores a data table of values. Two different Session variables are this way used for permanent and temporary addresses.One More thing is that my popup is a common one..ie wherever address is needed it is called.

Using session variable degrades the performance i know.

What is the best way to transfer value from one page to another?
Posted
Comments
   
Still, session variables. Or, alternatively, database itself. It depends on your application.
--SA

See there are multiple options you have for transfering data from one page to another.
Like Cookies, Hidden fields, Session, QueryString etc.
For more info you can check this link[^]

Its all depend upon your requirements, each & every approch has some merits & demerits.

Check out this link[^], It explains advantages & disadvantages of each & every approch.

Transferring page values to another page[^]
   
You can send data from one page to another by using following techniques:

-View state
-Control state
-Hidden fields
-Cookies
-Query strings
-Application state
-Session state
-Profile Properties

All are the best way for sending the data one page to another :)

Actually sending the data from one page to another, depends on data size and type.

I am giving the some example base in my experience like

* If I need to pass value like int, string etc. means small size data it good to use Query string. You can encrypt the data if you have security issue.

* If you need to pass some Object or XML (Again small Size) you can use the session Object.

* But, if you need to pass large data better to use session management. In this you have three options InProc, Out Pro and SQL.

* If you need to pass some control values from one page to another page better to use page posting
   
Hi,

You may use delegate.

Example code:

In you client code:
<%@ Register Assembly="AjaxControlToolkit" 
Namespace="AjaxControlToolkit" TagPrefix="cc1" %> 

<%@ Register Src="~/UserControls/City.ascx" 
TagName="ucSearchCityAddr" TagPrefix="uc1" %>



<cc1:ModalPopupExtender  runat="server" ID="mpeSearchCityAddr" TargetControlID="hfSearchCityAddr"
  PopupControlID="panelSearchCityAddr" BackgroundCssClass="modalBackground" DropShadow="true"
  Y="40">
</cc1:ModalPopupExtender>
<asp:Button SkinID="skinButtonM" runat="server" ID="hfSearchCityAddr" Style="display: none" />
<asp:Panel runat="server" Width="80%" ID="panelSearchCityAddr" Style="display: none;">
   <uc1:ucSearchCityAddr  runat="server" ID="ucSearchCityAddr" />
</asp:Panel>




C#
// In your .aspx Code behind...
protected void Page_Load(object sender, EventArgs e)
{       
    // SearchCityAddr------
    ucSearchCityAddr.SendValue += delegate(string cityName, string cityCode)
    {
        this.txtCityCode.Text = cityCode;
        this.txtCityName.Text = cityName 	
    };
    // Some code...
    //...
} 

public void CloseModalCityAddr()
{
   mpeSearchCityAddr.Hide(); 
}



// In your Web User Control Code behind..
public delegate void SendCityAddr(string cityName, string cityCode);
public event SendCityAddr SendValue;

// Some code...
//...

protected void lnkCityName_Click(object sender, EventArgs e)
{
   LinkButton lnkCityName = (LinkButton)sender;
   GridViewRow row = (GridViewRow)lnkCityName.NamingContainer;
   if (SendValue != null)
   {
      SendValue(((LinkButton)row.FindControl("lnkCityName")).Text,
      ((Label)row.FindControl("lblCityCode")).Text);
      Page.GetType().InvokeMember("CloseModalCityAddr",System.Reflection.BindingFlags.InvokeMethod, null, Page, null);

   }
}



Hope this could help...

Regards,
   
v2
Dude My Suggesion is to use querystrings it works
   

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900