Click here to Skip to main content
15,881,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview in that one View LinkButton. When click on Linkbutton open a new window. The problem here is click on the Refresh Button or F5 button. opened the another Window. How to prevent the Refresh button and F5 button in my page.

Code for View Link Button:
VB
  Try
        'When Clicking on the View LinkButton. It will Redirect to the demo Page.

            Dim lbnDetails As LinkButton = CType(sender, LinkButton)

            '*** Creating Object for GridViewRow
            Dim gvRow As GridViewRow = CType(lbnDetails.NamingContainer, GridViewRow)
            '*** Getting Values of Fields Using DataKeyNames
          objLeaseSearch.LeaseID = gvwLeaseReviewSummary.DataKeys(gvRow.RowIndex).Values(0)
            objLeaseSearch.LeaseVersionNumber = gvwLeaseReviewSummary.DataKeys(gvRow.RowIndex).Values(1)
   ScriptManager.RegisterStartupScript
(Me.Page, Me.GetType(), "Window", "ViewInternalID();", True)

        Catch ex As Exception
            SetUserMessage(ex.Message, MessageType.ErrorMessage)
            ErrorSignal.FromCurrentContext.Raise(ex)
        End Try
    End Sub


javascript code is :
JavaScript
function ViewInternalID()
     {

        window.open("demo.aspx",'_blank','width=800px,height=500px,scrollbars=yes, status=no, resizable');

    }


Please any one help me...
Posted
Updated 23-Jul-12 19:00pm
v5

1 solution

Hi,

Search for GET after POST - http://en.wikipedia.org/wiki/Post/Redirect/Get - basically, redirect to the current page after you're finished processing your event.

Something like:
C#
Response.Redirect(Request.RawUrl)


Here is an article for Detecting Page Refresh[^].

And also see:
http://stackoverflow.com/questions/553227/refresh-the-page-after-a-postback-action-in-asp-net[^]
http://stackoverflow.com/questions/7527243/save-button-click-event-getting-fired-up-on-refreshing-the-page-once-done-with-b[^]


Here is a similar discussion:
Avoid button click event on page refresh[^]
I'll recommend you to see this.
--Amit
 
Share this answer
 
v3
Comments
CH Guravaiah 23-Jul-12 6:11am    
could u explain brief description of that. please
_Amy 23-Jul-12 6:15am    
Check my updated answer.
CH Guravaiah 23-Jul-12 6:21am    
i am added in view linkbutton at Try

'When Clicking on the View LinkButton. It will Redirect to the demo Page.

Dim lbnDetails As LinkButton = CType(sender, LinkButton)

'*** Creating Object for GridViewRow

Dim gvRow As GridViewRow = CType(lbnDetails.NamingContainer, GridViewRow)

'*** Getting Values of Fields Using DataKeyNames

objLeaseSearch.LeaseID = gvwLeaseReviewSummary.DataKeys(gvRow.RowIndex).Values(0)

objLeaseSearch.LeaseVersionNumber = gvwLeaseReviewSummary.DataKeys(gvRow.RowIndex).Values(1)

ScriptManager.RegisterStartupScript

(Me.Page, Me.GetType(), "Window", "ViewInternalID();", True)

Response.Redirect(Request.RawUrl) Catch ex As Exception

SetUserMessage(ex.Message, MessageType.ErrorMessage)

ErrorSignal.FromCurrentContext.Raise(ex) End Try End Sub

After adding this code Response.Redirect(Request.RawUrl). in my page cleared all data.
_Amy 23-Jul-12 6:25am    
Store your data in session and persist that again in your page. That is the only solution which I found .
CH Guravaiah 23-Jul-12 6:31am    
I was used Viewstate in page.

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