ramya
ramya

Reputation: 1

Loading .aspx page

We have a HTML page(suppose links.html) with many links. When I click on certain link it redirects me to new HTML page(for one link one new html page) and data related to that link will be displayed on that new html page from SQL server. Now coming to our requirement we need to create a new single .aspx page which should display the data from SQL server dynamically based on the link which we click on the links.html page.

My questions are:

  1. Should I change the code of links.html page onclick event so that it can re-direct me to new .aspx page?

  2. How can I pass the value of particular link on link.html page to new .aspx page so that it displays that selected link data?

Upvotes: 0

Views: 227

Answers (2)

Karl Anderson
Karl Anderson

Reputation: 34846

The two most common solutions to this problem are:

  1. Query string parameters

    Pros:

    • Very simple to see what values are being passed.
    • Built-in .NET capability.
    • Useful for bookmark or favorites functionality in an application, because the page can be loaded up using the query string value; not dependent upon data being in a certain state in the application.

    Cons:

    • Each browser has a theoretical limit with Internet Explorer being the smallest at 2,048 characters.
    • Passing representation of objects is not possible with query strings (i.e. a list of Customer class objects).
    • Represents a potential security risk in that values are exposed. DO NOT pass any sensitive information in a query string.
  2. In-process session state variables

    Pros:

    • Built-in .NET capability.
    • Allows for storage of large and complex objects, such as list of Customer objects.
    • Resides in memory so you do not need to remember to keep on passing the value between page navigation.

    Cons:

    • It is volatile as it is in memory, must keep checking to see if data is actually there or not.
    • Can significantly increase the memory usage of your application; this is an issue if you are not the only application on your server.

Upvotes: 0

Tony
Tony

Reputation: 17637

You can pass information using the Query String, for example:

On your HTML:

<a href="MyPage.aspx?linkID=9">Goto page 9</a>

Then in your ASPX code behind:

protected void Page_Load(object sender, EventArgs e)
{    
    String linkID = Request.QueryString["linkID"];    
}

Upvotes: 1

Related Questions