This is a migrated thread and some comments may be shown as answers.

Issues with closing a rad window

1 Answer 81 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 31 Aug 2012, 10:10 AM
Hi,
I currently open a page from another radwindow using the code...

Protected Sub RadGrid1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadGrid1.SelectedIndexChanged
    If RadGrid1.SelectedItems.Count > 0 Then
        For Each item As GridDataItem In RadGrid1.SelectedItems
            Dim strid As String
            strid = item("UniqueID").Text
            Session("Selected") = "Selected"
            Session("ID") = strid
 
            Dim newwindow As New RadWindow
            newwindow.NavigateUrl = "MessageForm1.aspx"
            RadWindow1.Windows.Add(newwindow)
            newwindow.Width = Unit.Pixel(600)
            newwindow.Height = Unit.Pixel(650)
        Next
    End If
End Sub

And everything opens fine, until I come to closing it, I know everything works because It works perfectly using "response.redirect"
When I close it using the following code...
Protected Sub btnSave_Click(sender As Object, e As System.EventArgs) Handles btnSave.Click
 
    Dim log As New dbMessageLog()
    log.ForID = Convert.ToInt32(ddlFor.SelectedValue)
    log.From = Convert.ToString(ddlFrom.SelectedValue)
    log.Customer = txtCustomer.Text
    log.Telephone = txtTelephone.Text
    log.Email = txtEmail.Text
    log.Urgent = Convert.ToInt32(chkUrgent.Checked)
    log.TakenByID = Convert.ToInt32(ddlTakenBy.SelectedValue)
    log.TakenOn = Convert.ToDateTime(DatePicker.SelectedDate)
    log.Actioned = 1
    log.StatusID = Convert.ToInt32(ddlStatusID.SelectedValue)
    log.Message = txtMessage.Text
    log.Subject = TextBox1.Text
 
    If lblMessageID.Text = zero Then
        log.Create(log)
    Else
        log.UniqueID = lblMessageID.Text
        log.Update(log)
    End If
    InjectScript.Text = "<script type='text/javascript'>CloseAndRebind();</" + "script>"
    Session("ID") = zero

On First Click...
It saves the data but doesn't close the window, and displays the old values
the screen flickers slightly as well
However
On a second click of the save button it works fine

It also does it when I click on the "x" at the top right of the page
so i guess it's something to do with the opening code?

Thanks in advance
Ryan

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 03 Sep 2012, 02:59 PM
Hi Ryan,

What I can suggest is the following

1) open the RadWindow in a client-side event, if possible, because instances can be created on  the client during runtime. If you cannot go client-side - employ the approach from this sticky thread: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx.

2) examine this help article on properly injecting the script call: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-javascript-from-server-side.html. Using a label is not the most effective way of doing this. I have found the ScriptManager.RegisterStartupScript() method to be the most reliable.


Kind regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
Ryan
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or