Question : Replace ButtonClickEvent with RadWindow Close (ASP.NET, C#, Telerik RadControls)

How do I change the ButtonClickEvent (C#) to the Telerik RadCloseWindow Client Side Event.  

The code "samples" from telerik show the NET and Javascript related to the Telerik RadWindow.  This action needs to then Fire off the C# tasks that the "Back to Lesson Selector" button does. THIS CODE IS NOT CURRENTLY IN MY SOLUTION. The problem is more javascript calling c# which is not my forte.

The Button Click event starts a number of C# tasks which include updating an MSSQL 2008  database as well as running some java to dynamically update the display of the the RadGrid database video 'hits'.  This IS the ACTUAL C# Code that needs to be controlled by the client side radwindow close.

My plan is to run it direct from the VideoSelector Page (embedded user control XGISVideoLessonVideo.jpg).  

The reason for this is to help resolve seperate display animation and resize issues/conflicts which play havoc with the radwindow display and the "Back to Lesson Selector" button .  ie the "Back to Lesson Selector" button is clicked but the RadWindow Repoens.  The Telerik animation is beneficial as it helps resolve image and video size differences, eliminating the need for setting fixed widths (for variable objects) which cause scrollbars to uneccesarily display.  The idea is that if I remove the dependency on the back button to the radwindow close event it will also resolve display issues I am having in IE8 vs correct display in chrome. ie less things to go wrong.

The endgame is to replace the 2nd ASPX page and run it all from the one page.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
function controlWindowButtons()
            {
                var selitem = null;
                var e = document.forms[0].elements["RadioButtonList1"];
                for (var i=0; i < e.length; i++)
                {
                 if (e[i].checked)
                    {
                     selitem = e[i].value;
                    }
                } 
                eval("oWnd." + selitem);
            }
1:
onclick="controlWindowButtons()" Value="close()" Text="Close"
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
protected void Button1_Click(object sender, EventArgs e)
    {
        string sql = "";
        var com = new SqlCommand();
        sql +=
            "INSERT INTO Xtrain.XTV7_3_Video_View (XTV7_VVR_Time_Start, XTV7_VVR_Time_Close, XTV7_UserName, XTV7_Videos_ID) Values (@XTV7_VVR_Time_Start, @XTV7_VVR_Time_Close, @XTV7_UserName, @XTV7_Videos_ID)";
            //Geek.XTV7_VidReg;
        com.Parameters.Add("@XTV7_VVR_Time_Start", SqlDbType.DateTime).Value = DateTime.Parse(lblVidReg.Text);
        com.Parameters.Add("@XTV7_VVR_Time_Close", SqlDbType.DateTime).Value = DateTime.Parse(DateTime.Now.ToString());
        com.Parameters.Add("@XTV7_UserName", SqlDbType.NVarChar).Value = HttpContext.Current.User.Identity.Name.ToString();
        com.Parameters.Add("@XTV7_Videos_ID", SqlDbType.Int).Value = Int32.Parse(Geek.XTV7_Videos_ID.ToString());

        try
        {
            data.ExecuteNonQuery(sql, com);
        }
        catch (Exception ex)
        {
            string script = "<script language=\"JavaScript\">alert('Error :  " + ex.Message + "');</script>";
            Page.RegisterStartupScript("error", script);
        }
        ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);

        string scriptreturn = "<script type='text/javascript'>closeRadWindow('VideoViewer.aspx');</script>";
        ClientScript.RegisterStartupScript(GetType(), "Redirect", scriptreturn, false);
    }
1:
2:
3:
4:
5:
6:
Current Javascript Close andRebind

         function CloseAndRebind(args) {
                GetRadWindow().BrowserWindow.refreshGrid(args);
                GetRadWindow().close();
            }
Attachments:
 
2nd DisplayASPX Page with BackButton (Current)
2nd DisplayASPX Page with BackButton (Current)
 
 
VideoSearchAndStart Page
VideoSearchAndStart Page
 

Answer : Replace ButtonClickEvent with RadWindow Close (ASP.NET, C#, Telerik RadControls)

Problem Solved:

The code below + the removal of the asp button and most importantly relocating the insert statement to a private void on the host page.


JAVASCRIPT

        function onClose() {
            $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("closed");
            GetRadWindow().close();

        }


XHTML

<telerik:RadWindow runat="server" ID="RadWindow1" Behaviors="Reload,Resize,Minimize,Maximize,Close"
            VisibleTitlebar="true" VisibleOnPageLoad="false" Animation="Fade" Title="XGIS Lesson Video Viewer"
            AutoSize="true" Width="1050px" Height="670px" VisibleStatusbar="false" KeepInScreenBounds="True"
            Skin="Black" OnClientClose="onClose">
        </telerik:RadWindow>



C#


    #region Ajax Manager Request
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        switch (e.Argument)
        {
            case "closed":
                UpdateView();
                RadGrid1.Rebind();
                break;
        }
    }
    #endregion
Random Solutions  
 
programming4us programming4us