By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,526 Members | 2,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,526 IT Pros & Developers. It's quick & easy.

How do I get my link button to redirect correctly in ASP.net ?

P: 3
This problem only occurs in Firefox....

I have a page (page 1) with a link button. The link button uses response.redirect to pass parameters and take me to a second page (page 2) when the lnkButton_click event is fired. Most of the time, the functionality works.

However, if a user clicks any other button on the page and then comes back to page 1 using the browser's back button, the link button redirects to that last page. Meaning, the user is directed to the page that they just returned from using the back button and does not go to where they should go (page 2).

When I step through, I notice that the lnkButton_clink event does not even fire. I do see that some sort of javascript is firing ... Javascript (,,DoPostBack) .... How can I force my lnkbutton to redirect to the correct page when the back button is previously used?
Sep 9 '08 #1
Share this Question
Share on Google+
5 Replies


shweta123
Expert 100+
P: 692
Hi,

You can use one of the following two methods to redirect page using linkbutton control :
1> You should set PostBackUrl property of the LinkButton control in order to redirect to the required page when LinkButton control is clicked.
2> You can write the code in LinkButton1_Click event in order to redirect to the required page.
Sep 9 '08 #2

P: 3
I do have code in the click event because I need to pass parameters. The problem is the click event never fires when using Firefox. I click the link button and it automatically defaults back to the page from where the user returned.

Expand|Select|Wrap|Line Numbers
  1. Protected Sub lnkSection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkSection.Click
  2.  
  3.         Dim EmployeeID As String = Request.QueryString("empid")
  4.         Dim UnitID As String = GetUnitID(EmployeeID)
  5.         Response.Redirect("UnitListing.aspx?unitid=" & UnitID & "&empid=" & EmployeeID)
  6.  
  7.     End Sub
  8.  
Sep 9 '08 #3

shweta123
Expert 100+
P: 692
Hi,

You should write the code to fire the event lnkSection_Click() on Onclick event of linkbutton. e.g.

<asp:LinkButton ID="LinkButton1" runat="server"
OnClick = "lnkSection_Click" >LinkButton</asp:LinkButton>



Protected Sub lnkSection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkSection.Click

Dim EmployeeID As String = Request.QueryString("empid")
Dim UnitID As String = GetUnitID(EmployeeID)
Response.Redirect("UnitListing.aspx?unitid=" & UnitID & "&empid=" & EmployeeID)
End Sub
Sep 10 '08 #4

P: 3
Hi,

You should write the code to fire the event lnkSection_Click() on Onclick event of linkbutton. e.g.

<asp:LinkButton ID="LinkButton1" runat="server"
OnClick = "lnkSection_Click" >LinkButton</asp:LinkButton>



Protected Sub lnkSection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkSection.Click

Dim EmployeeID As String = Request.QueryString("empid")
Dim UnitID As String = GetUnitID(EmployeeID)
Response.Redirect("UnitListing.aspx?unitid=" & UnitID & "&empid=" & EmployeeID)
End Sub

I added the OnClick code but still have the same problem. I am wondering if this is a browser issue. It only occurs with Firefox 3.0 .
Sep 10 '08 #5

shweta123
Expert 100+
P: 692
Hi,

Please read

This discussion regarding the problem you are getting.
Sep 11 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.