Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Alert script are not working in a gridview (delete rowbound) my code is here. Advance thanks.
VB
Protected Sub Delete_onGridRow_Click(ByVal sender As Object, ByVal e As EventArgs)
        Try
            ostate = New BLstate

            str = DirectCast(sender, System.Web.UI.WebControls.ImageButton).CommandName.ToString
            With ostate
                .stateid = str
            End With

            result = state.state_delete(ostate)

            If result > 0 Then
                gvList.DataSource = state.Listview(txtstate.Text, ddstateStatus.SelectedValue)
                gvList.DataBind()
                'Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "alert", "alert('item not deleted');", True)
                'Page.ClientScript.RegisterStartupScript(Me.GetType, "alert", "showDialog('Warning','Item not deleted.','warning');", True)
                'Response.Write("item not deleted")
                Response.Write("<script type=text/javascript>alert('item not deleted')</script>")
                NoDataLabel.Text = "item not deleted"
            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
Posted
Updated 28-Dec-11 22:37pm
v2

You can use ScriptManager if you are using AJAX

ScriptManager.RegisterStartupScript(this,this.GetType(), DateTime.Now.Tostring(), "alert('Hi');",true);


Thanks
Vinod
 
Share this answer
 
Comments
Vasim889 29-Dec-11 6:46am    
it's not working
try by changing this line..

C#
Response.Write("<script language='javascript'>alert('item not deleted');</script>")


hope it works..
 
Share this answer
 
v2
Comments
Vasim889 29-Dec-11 4:43am    
It's not working?but my script work in page load!
Change below line
Response.Write("<script type=text/javascript>alert('item not deleted')</script>")

with below line

this.ClientScript.RegisterStartupScript(this.GetType(), "%#######%", "alert('Hi');",true);
 
Share this answer
 
Comments
Vasim889 29-Dec-11 6:46am    
it's not working

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