Click to See Complete Forum and Search --> : Pop-up alert do not show


sweet_babylhyn
June 5th, 2009, 04:19 AM
Hello guys, I'm here again. After a few searched on google, I came out an idea on how to used pop up alert and I'm stuck again...


Protected Sub btnXML_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnXML.Click
dim participant_id as string
.
.
.
.
If Len(participant_id) = 0 Then
Me.PopupAlert("The user has no assigned participant")
Exit Sub
ElseIf Me.lstSeller.SelectedIndex = -1 Or Me.lstResource.SelectedIndex = -1 _
Or Me.lstBuyer.SelectedIndex = -1 Then
Me.PopupAlert("Check each filter values!...")
Exit Sub
ElseIfparticipant_id <> me.txtBCQBuyer.text Then
Me.PopupAlert("The values has changed, Reload the data...")
Me.ViewData()
End If
.
.
.
.
Response.ClearHeaders()
Response.AddHeader("content-disposition", "attachment;filename=tmp")
Response.ContentType = "xml"
Response.Write(tmpXML.OuterXml.ToString)
Response.Flush()
Response.Close()
End Sub





Public Sub PopupAlert(ByVal str As String)
Dim script As String
script = "<script type=text/javascript>alert('" + str + "');</script>"

Dim tmpPage As Page = HttpContext.Current.CurrentHandler

If Not tmpPage Is Nothing And Not tmpPage.ClientScript.IsClientScriptBlockRegistered("alert") Then
tmpPage.ClientScript.RegisterClientScriptBlock(Page.GetType, "alert", script)
End If

End Sub





Public Sub ViewData()
dim dt as new DataTable
.
.
.
.

Me.GridView.DataSource = dt
Me.GridView.DataBind()

End Sub



the first and second condition below works fine. It pop the alert window if its satisfy the condition.

If Len(participant_id) = 0 Then
Me.PopupAlert("The user has no assigned participant")
Exit Sub
ElseIf Me.lstSeller.SelectedIndex = -1 Or Me.lstResource.SelectedIndex = -1 _
Or Me.lstBuyer.SelectedIndex = -1 Then
Me.PopupAlert("Check each filter values!...")
Exit Sub


but the third condition below doesnt pop - up the alert window and the datagrid doesnt refresh even it satisfy the condition. I used to debug and it read the PopAlert and View Data but it did not show the alert and did not refresh also the datagrid. The last thing it do is download the XML. What do you think is the problem.... But when I used a MSGBOX, it came right but I think it will cause me a problem upon deployment if I will use it...



ElseIfparticipant_id <> me.txtBCQBuyer.text Then
Me.PopupAlert("The values has changed, Reload the data...")
Me.ViewData()
End If

dannystommen
June 5th, 2009, 06:17 AM
I see you use

tmpPage.ClientScript.RegisterClientScriptBlock(Page.GetType, "alert", script)


This code works fine when a control (in your case btnXML) is not on an UpdatePanel. So my guess is that you are using an updatePanel.

Am I correct?

sweet_babylhyn
June 7th, 2009, 08:53 PM
Nope, UpdatPanel works only on 3.5. I used only 2.0. What do you think is the problem?
My Datagridview doesn't refresh also.

sweet_babylhyn
June 8th, 2009, 11:32 PM
I see it now, there's no problem on my pop-up alert. If I remove the code below, it shows the pop-up alert and the same time my datagridview refresh already. But how can I do this, before it download the xml file, it will show first the pop-up alert and refresh my datagridview.

Any suggestion guys....



Response.ClearHeaders()
Response.AddHeader("content-disposition", "attachment;filename=tmp")
Response.ContentType = "xml"
Response.Write(tmpXML.OuterXml.ToString)
Response.Flush()
Response.Close()