0

I click a button in Article.aspx, after finished processing, I want it returnto another page previous page, SectionOver.aspx, and I also want it contains previous searching results.

asp.net

<asp:Button ID="btnSaveArticle" runat="server" Text="<%$ Resources:General, Action_Save %>" Width="100px" OnCommand="btnSaveArticle_Command" OnClientClick="return ConfirmSave();  " />

c#:

protected void btnSaveArticle_Command(object sender, CommandEventArgs e){          
        saveArticleProcess(e.CommandArgument.ToString(), "Save");
        btnCancel_Command(null, null);
    }
protected void btnCancel_Command(object sender, CommandEventArgs e)
    {
        if (IsPostBack)
        {
            btnUnlock_Click(null, null);
            Response.Redirect("SectionOverview.aspx");
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "_ReloadPage", "closeWindowevent()", true);
        }
    }

it can back to previous page, but that is a page, it does not contain previous searching results.

rivahuang
  • 3
  • 3

1 Answers1

0

After you get the result from search, which I am assuming is large amount of data. You can put it in cache and retrieve it at the other end.

Something like:

To Insert:

HttpContext.Current.Cache.Insert("UNIQUE SEARCH KEY", dataTable, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);

To Retrieve

public DataTable GetDataTableFromCacheOrDatabase()
{
   DataTable dataTable = HttpContext.Current.Cache["UNIQUE SEARCH KEY"] as DataTable;
   if(dataTable == null)
   {
       dataTable = GetDataTableFromDatabase();
       HttpContext.Current.Cache["UNIQUE SEARCH KEY"] = dataTable;
   }
   return dataTable;
}

If you only have small data, then you can also use query string.

string s = "~/SectionOverview.aspx?";
s += "Id=" + someId;
Response.Redirect(s);

to retrieve

Request.QueryString["Id"];

Ref and Ref

Community
  • 1
  • 1
Yahya
  • 3,386
  • 3
  • 22
  • 40