Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 585563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:00:57+00:00 2026-05-13T15:00:57+00:00

I have an asp page (Default.aspx) that displays the diff between two text files.

  • 0

I have an asp page (Default.aspx) that displays the diff between two text files. It contains two drop down lists (ID=”File1″ and “File2″ respectively) and a button (ID=”Submit”).

It also contains a Literal control with ID “Result”.

The contents of the list button are populated based on the files present in the physical application path.

Each time the submit button is clicked, I want to give the result of the diff/comparison in the Literal control, So I have an event handler like this:

protected void Submit_Click(object sender, EventArgs e)
{
    Result.Text = CompareFiles(File1.SelectedValue, File2.SelectedValue);
}

The problem with this is that you cannot bookmark the results of the comparison between specific files.

To solve this problem I appended the values of the files chosen for comparison as query string to the URL and performed a redirection. And therefore, the changed the above event handler to look like this:

protected void Submit_Click(object sender, EventArgs e)
        {
            string build1 = DropDownList1.SelectedValue;
            string build2 = DropDownList2.SelectedValue;

            string queryString = 
                String.Format("?file1={0}&file2={1}",HttpUtility.UrlEncode(build1),HttpUtility.UrlEncode(build2));

            string redirectionUrl = Request.Url.AbsolutePath + queryString;

            Response.Redirect(redirectionUrl, true);
        }

Accordingly called the “CompareFiles” method in the “Page_Load” event handler. So now, you can bookmark the results of the comparison and load it again directly because the URL would contain the files to compare.

But the problem is that “IsPostBack” property is false each time the redirection happens. Therefore, the values of the DropDownLists (files present in the physical application directory) gets evaluated each time.

I do not want this to happen if it is a redirection from the same page. How can I do this? I only want it to happen if the page is accessed for the first time or is accessed from some other page.

Is this a bad practice? I mean redirecting to the same page. I can avoid this problem by giving the results in a different page, But I want to do it this way, because I want the DropDownLists and the “Submit” buttons to always be there.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:00:58+00:00Added an answer on May 13, 2026 at 3:00 pm

    Since you are redirecting the to same page, it is NOT a postback, viewstate is lost, and it must re-bind the contents.

    More than likely, just put the values for the DropDownLists into cache, then you can load from cache, and only hit the file system if not in cache.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 432k
  • Answers 432k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is exactly what you'll need: http://doc.qt.io/qt-5/qimage.html#reading-and-writing-image-files Google is your… May 15, 2026 at 2:30 pm
  • Editorial Team
    Editorial Team added an answer While creating this question we found the solution. It appears… May 15, 2026 at 2:30 pm
  • Editorial Team
    Editorial Team added an answer var orders = db.Orders.Where(m => m.OrderItems.Any(i => i.OrderId == 5)).ToList(); May 15, 2026 at 2:30 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.