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

Request.Form["__EVENTTARGET"] is null while __doPostBack() on close a window in clientside

2 Answers 184 Views
Window
This is a migrated thread and some comments may be shown as answers.
Abhi
Top achievements
Rank 1
Abhi asked on 05 Sep 2012, 01:50 PM
Hello,
I have a MDI web form and dynamically creating new radwindows inside that MDI form. I want to some operations on close (X) of that window. For that i have added RadWindow1.OnClientClose = "OnClientCloseClick"; . In OnClientCloseClick event, i have called __doPostBack() in order to implement my logic. On closing window, postback is working. But when i am checking  Request.Form["__EVENTTARGET"] , it's value becomes null. When i am doing the same in a normal aspx page(no windowmanager here), it is showing some value.
             In MDI form  i have added new window dynamically.
    protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                RadWindow RadWindow1 = new RadWindow();
                RadWindow1.ID = "RadWindow1";
                RadWindow1.VisibleOnPageLoad = true;
                RadWindow1.OnClientClose = "OnClientCloseClick";
                RadWindow1.NavigateUrl = String.Format("Default.aspx?ID=" + Request.QueryString["ID"]);
                RadWindowManager1.Windows.Add(RadWindow1);
}
}
JS
 function OnClientCloseClick(sender, args) {
                   __doPostBack('SaveSettingOnClose', 'OnClose');
                   }
function __doPostBack(eventTarget, eventArgument) {
           document.Form1.__EVENTTARGET.value = eventTarget;
           document.Form1.__EVENTARGUMENT.value = eventArgument;
           document.Form1.submit();
        }
HTML
<input type="hidden" name="__EVENTTARGET" value="">
    <input type="hidden" name="__EVENTARGUMENT" value="">

---------------
In Default.aspx (new window created)
in page load
 if (Request.Form["__EVENTTARGET"] == "SaveSettingOnClose")
            {

                SaveSettingOnClose();

            }
Here Request.Form["__EVENTTARGET"] becomes null. so control is not going inside the if block.

Please provide me solution to solve this issue.

Thanks
Abhi

2 Answers, 1 is accepted

Sort by
0
Accepted
rdmptn
Top achievements
Rank 1
answered on 06 Sep 2012, 11:41 AM
OnClientCloseClick is in the context of the parent page and the postback happens in the parent page. This means that the page you load inside the RadWindow will not be posted back. If your RadWindow is viisible on page load with the main page then the content page will be loaded anew and __EventTarget will be empty, of course.

It seems you need to initiate the postback in the content page, so you need the approach from this article: http://www.telerik.com/help/aspnet-ajax/window-programming-calling-functions.html.
0
Abhi
Top achievements
Rank 1
answered on 07 Sep 2012, 04:43 AM
Hi rdmptn,

thank you for your reply. Now it is working fine.

In MDI.aspx

function OnClientCloseClick(sender, args) {
                var oWnd = GetRadWindowManager().getWindowByName("RadWindow1");
                oWnd.get_contentFrame().contentWindow.SaveSettingOnClose();
            }
if (!Page.IsPostBack)
            {
                RadWindow RadWindow1 = new RadWindow();
                RadWindow1.ID = "RadWindow1";
                RadWindow1.VisibleOnPageLoad = true;
                RadWindow1.OnClientClose = "OnClientCloseClick";
                RadWindow1.NavigateUrl = String.Format("Default.aspx?ID=" + Request.QueryString["ID"]);
                 RadWindowManager1.Windows.Add(RadWindow1);
}

In default.aspx

function SaveSettingOnClose() {
            __doPostBack('SaveSettingOnClose', 'OnClose');
        }

Thanks
Abhi
Tags
Window
Asked by
Abhi
Top achievements
Rank 1
Answers by
rdmptn
Top achievements
Rank 1
Abhi
Top achievements
Rank 1
Share this question
or