[Solved] ScriptManager.RegisterStartupScript not working with ASP.Net UpdatePanel

makumbi
 
on Apr 25, 2022 02:56 AM
886 Views

message box not coming after adding update panel on my webpage

please help

Using Con As New SqlConnection(conString)
    Con.Open()
    Using Com As New SqlCommand("Select * from Controlcream where stream = '" & streamr & "'", Con)
        Using RDR = Com.ExecuteReader()
            If RDR.HasRows Then
                ' Response.Write("<script>alert('No Stream is Allowed to Cream Class');</script>")
                Dim time2 As String = "No Stream is Allowed to Cream Class"
                Dim script2 As String = "window.onload = function() { askConfirm('" & time2 & "'); };"
                ' ClientScript.RegisterStartupScript(Me.GetType(), "askConfirm", script2, True)
                '  ScriptManager.RegisterStartupScript(Me.GetType(), "askConfirm", script2, True)
                ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "Message", "alert('" + script2 + "');", True)

                '
                DropDownList.ClearSelection()
                Dim item As Object = DropDownList.Items.FindByText("Please select")
                If item IsNot Nothing Then
                    item.Selected = True
                End If
                ScriptManager.RegisterStartupScript(Me, [GetType](), "displayalertmessage", "Showalert();", True)
            End If
        End Using
    End Using
End Using

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
makumbi
 
on Apr 28, 2022 01:51 AM

solution was to use this

Dim message As String = "alert('THIS STREAM IS ALREADY FULL.')"
ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "alert", message, True)