Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i have a page say page1.aspx where i have many anchor tags like sony,samsung,dell,micromax etc.. when i click on any of these tags(ie sony,samsung,dell,micromax) .page1.aspx will redirect to page2.aspx...where data change based on the anchor tag i used.for example... if i use sony..the content in page2.aspx will show details of sony only... likewise... now my question is how can i achieve dis using session.
Posted
Updated 25-Sep-14 1:06am
v3
Comments
Sinisa Hajnal 25-Sep-14 6:15am    
Describe your setup in more detail. Also, what do you mean by value of an anchor tag? Its href? Or you have some html5 "data-" attributes? Or something completely different?
jin19 25-Sep-14 6:34am    
i have many anchor tags,i need to go to same page where datas may change based on user click on the anchor tag.. i need to achieve this using session... how can i do it in Asp.net C#
Sinisa Hajnal 25-Sep-14 6:45am    
Yes, you said the same thing in your question. This doesn't clarify it. I'm not even sure that Leena solution addresses your problem - it just suggests how you can hide some links on the same page, but you don't describe where those anchor tags are nor what data can change and how.
jin19 25-Sep-14 7:04am    
i have a page say page1.aspx where i have many anchor tags like sony,samsung,dell,micromax etc.. when i click on any of these tags(ie sony,samsung,dell,micromax) .page1.aspx will redirect to page2.aspx...where data change based on the anchor tag i used.for example... if i use sony..the content in page2.aspx will show details of sony only... likewise... now my question is how can i achieve dis using session...hop everything is clear
Sinisa Hajnal 25-Sep-14 7:13am    
Much better :)

Is session mandatory (that is, is there a reason you're not using link parameters? like page2.aspx?selection=Sony

You should rename your pages :)

On your server side handler for all clicks.

You also need to have all anchors runat="server" and NavigateUrl / href = "#" so that they redirect after they run through server side code. (or at least I think they will redirect before going server-side, you may check that before doing it...)

C#
protected void anchor_click (object sender, EventArgs e) {
    Session("manufacturer") = "Sony"; // here you need to get the value of the clicked anchor

    Response.Redirect("Page2.aspx", true);
}



Better solution is to set queryString parameters during loading and then you don't have to handle clicks, they will redirect properly and on page2 you need to check queryString instead of session variable
 
Share this answer
 
v3
Yes, it can be achieved by using session,
on page load check what session returns, on the basis of that show only that anchor tag, hide others
you need to give Id to your anchor tag.
 
Share this answer
 
Comments
jin19 25-Sep-14 6:31am    
can u elaborate ?
Leena 206 26-Sep-14 0:51am    
You can implement as given in Solution-2 .

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