Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Dim strmessageEdit As String
             strmessageEdit = "Record Deleted Successfully"
             Dim strScriptEdit As String = "<script runat=server language=JavaScript>alert('" & strmessageEdit & "');</script>"
             Page.RegisterStartupScript("clientScript", strScriptEdit)
             Response.Redirect("Add.aspx")


"Record Deleted Successfully" script window not open , it call open ass.aspx page, i want show "Record Deleted Successfully " message to user.
and redirect to Add.aspx page,

how it is possible?
Posted

The alert will never display because of the Response.Redirect call.

To make this work, use window.location in JavaScript to redirect the page after the alert and comment out the call to Response.Redirect.

VB
Dim strmessageEdit As String
    strmessageEdit = "Record Deleted Successfully"
Dim strScriptEdit As String = _
  "<script runat=""server"" language=""JavaScript"">alert('" & _
  strmessageEdit & _
  "'); window.location = '" &
  Page.ResolveUrl("~/Add.aspx") & _
  "';</script>"
Page.RegisterStartupScript("clientScript", strScriptEdit)
'Response.Redirect("Add.aspx")
 
Share this answer
 
Comments
sankar guru 30-Sep-10 1:24am    
Protected Sub GridView1_RowCommand()

If e.CommandName.Equals(#Quote#Delete#Quote#) Then
'Some code to delete and DataBind gridview

Dim strmessageEdit As String
strmessageEdit = #Quote#Record Deleted Successfully#Quote#
Dim strScriptEdit As String = #Quote#<script runat="server" language=JavaScript>alert('#Quote# & strmessageEdit & #Quote#'); window.location = '#Quote# & _
Page.ResolveUrl(#Quote#~/Add.aspx#Quote#) & #Quote#';</script>#Quote#
Page.RegisterStartupScript(#Quote#clientScript#Quote#, strScriptEdit)
'Response.Redirect(#Quote#Add.aspx#Quote#)
End If
End Sub

if i reomove #Quote#Response.Redirect(#Quote#Add.aspx#Quote#)#Quote# code means it show #Quote#The GridView 'GridView1' fired event Rowediting which wasn't handled.#Quote# Error Message
I do not think so it is feasible in the approach you are implementing. Ideally, it would run the entire function (your VB Code) and then call the Javascript.
If you want to do this type of operation, I would save the data and then call the JS Function, display the alert and then use __dopostback.
 
Share this answer
 
Try:
Dim strScriptEdit As String = "<script language = 'Javascript' >alert('" & strmessageEdit & "');</script>"
 
Share this answer
 
v4

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