More than one page posts using window.opener.window.document.forms[0].submit();

 I've wasted an afternoon and evening trying to find a solution to this weird problem.

 I have a preview page(default.aspx) and an edit page (editdefault.aspx) as content pages within nested master pages. They are also within an iframe which is not within the nested masters. There are lots of other pages within the top level master page.

I use a dynamically created asp:linkbutton to post from default.aspx to editdefault.aspx: 

Code behind:      

        LinkButton EditBtn = new LinkButton();
        EditBtn.CssClass = "BibVNavBtn";
        EditBtn.OnClientClick = "ToggleEdit('EditDefault.aspx',this);";
        EditBtn.ID = "EditBtn";
        EditBtn.Style.Add("position", "absolute");
        EditBtn.Style.Add("top", "5px");
        EditBtn.Style.Add("left", "10px");
        EditBtn.Text = "EDIT";
        EditBtn.ToolTip = "Edit this page";
        TaskBar.Controls.Add(EditBtn);

javascript: 

function ToggleEdit(URL,BtnClicked)
{
   var elements = window.document.all;
   for(var i=0; i<elements.length;i++){
       var ControlId = elements[i].id;
       if(ControlId.indexOf("BtnClicked") != -1)
       {
            document.getElementById(ControlId).value = BtnClicked.id;
       }
   }
    document.forms[0].action = URL;
    document.forms[0].submit();

}

in editdefault.aspx I have html buttons which open a popup window containing fckeditor RTE:

 <input type=button ID=EditTLC value="Edit Content" OnClick="javascript:OpenRTE('c1961TopLeftContent')"
        style="margin-left:0px;padding-left:0px;height:16px;font-size:7pt;"/>

javascript:

var oRTEWindow
var oText = new Object();


function OpenRTE(Element)
{
//debugger
   var elements = window.document.all;
   for(var i=0; i<elements.length;i++){
        var ControlId = elements[i].id;
        if(ControlId.indexOf(Element) != -1)
        {
            if(elements[i].tagName=="DIV")
            {
                var text = document.getElementById(ControlId).innerHTML;
                oText.text = text;
                oText.element = 'h'+Element;
            }
        }
    }

    var url = 'RTE.htm';
    if(oRTEWindow != null)
    {
        if(oRTEWindow.closed)
        {
            oRTEWindow = window.open(url,'EditTextBlock','width=850,height=700,resizable');
            oRTEWindow.focus();
        }
        else
        {
            oRTEWindow.close();
            oRTEWindow = window.open(url,'EditTextBlock','width=850,height=700,resizable');
            oRTEWindow.focus();
        }
    }
    else
    {
        oRTEWindow = window.open(url,'EditTextBlock','width=850,height=700,resizable');
        oRTEWindow.focus();
    }
    TopButtons();
    return false;

}

After editing in the popup the user posts changes back to the editdefault.aspx with the following javascript:

    function SaveToWindow()
    {
       var Ctrl = window.opener.oText.element;
       var elements = window.opener.document.all;
       var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
       var Text = oEditor.GetHTML();
       for(var i=0; i<elements.length;i++){
            var ControlId = elements[i].id;
            if(ControlId.indexOf(Ctrl) != -1)
            {
                if(elements[i].tagName=="DIV")
                {
                    if(window.opener.window.document.getElementById(ControlId))
                    {
                       window.opener.window.document.getElementById(ControlId).innerHTML = Text;
                    }
                }
                if(elements[i].tagName=="INPUT")
                {
                    if(window.opener.window.document.getElementById(ControlId))
                    {
                        window.opener.window.document.getElementById(ControlId).value = Text;
                    }
                }
            }
        }
        window.opener.window.document.forms[0].submit();
        window.close();

    }

The postback worked fine until today when I temporarily changed an html button on editdefault.aspx which redirects back to default.aspx, then changed it back again:

<input type=button  ID=PostBtn Value="PREVIEW CHANGES" style="visibility:visible" OnClick="javascript:TopNav('Default.aspx?ButtonClicked=PostBtn');return false;" /> 

Now the postback from the rte editor popup not only causes editdefault.aspx to postitself but also causes default.aspx to reload even though this is not explicitly called.

While stepping through the code I checked the request object in default.aspx. The UrlReferrer attribute pointed to editdefault.aspx and the request method was get.

It appears as though the  'window.opener.window.document.forms[0].submit();' caused an html input button on editdefault.aspx to fire a get to default.aspx without bothering to populate its querystring as well as doing what it was supposed to which was to post editdefault.aspx form!!!

How is this possible? 

 

 

0
engxladso
7/31/2008 9:01:25 PM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

1 Replies
1403 Views

Similar Articles

[PageSpeed] 9
Get it on Google Play
Get it on Apple App Store

I am astonished to discover that this bizarre double posting behaviour was apparently being caused by an asp:Image control losing its source value during the post. Why it would be losing this value I have no idea. When I made sure that this control regained its src string from a session variable in Page_Load, the second 'get' with null querystring from editdefault.aspx to default.aspx stopped!

If someone has an explanation for either why the image src is getting lost (no other controls are losing their state) or the bizarre double posting that resulted from it I would be very happy to hear it tomorrow! I am finally going to bed now at 00:15 having been working on this web site since 06:00. If I knew how buggy .NET was going to be, i would have stuck with old ASP. At least that works! 

 

0
engxladso
7/31/2008 11:19:06 PM
Reply:

Similar Artilces:

superreview requested: [Bug 297541] Using window.open to open a window at (0,0) does not work : [Attachment 186289] fix?
Robert O'Callahan (Novell) <roc@ocallahan.org> has asked Christopher Blizzard <blizzard@mozilla.org> for superreview: Bug 297541: Using window.open to open a window at (0,0) does not work https://bugzilla.mozilla.org/show_bug.cgi?id=297541 Attachment 186289: fix? https://bugzilla.mozilla.org/attachment.cgi?id=186289&action=edit ...

superreview granted: [Bug 297541] Using window.open to open a window at (0,0) does not work : [Attachment 186289] fix?
Boris Zbarsky <bzbarsky@mit.edu> has granted Robert O'Callahan (Novell) <roc@ocallahan.org>'s request for superreview: Bug 297541: Using window.open to open a window at (0,0) does not work https://bugzilla.mozilla.org/show_bug.cgi?id=297541 Attachment 186289: fix? https://bugzilla.mozilla.org/attachment.cgi?id=186289&action=edit ...

Calling parent window (using master page) button click event from an opened child window (not using master page)
I have a parent window that pops up a child window. In the child window, there is a server control LinkButton, with the following command at code-behind upon clicking:         Response.Write("<SCRIPT> javascript:window.opener.document.getElementById('<%=btnMas.ClientID%>').click(); </SCRIPT>");        Response.Write("<SCRIPT> javascript:window.close() </SCRIPT>");        Response.End(); What it would like to do are:1) Invoke the ...

how can I use window.opener but with window.showModalDialog instead of window.open
Hi, I tried the code bellow that I found in  :  4guysfromrolla site:the code displays a source page, whn I click on the Calendar <a href />  link  i get a calendar displayed on a target page. when I select a date, the calendar page closes and populates the textbox txtDate with the chosen date. Here is the code of the 2 pages and my question is down bellow:a source page called frmCalendar.aspx has this:<form name="frmCalendar">   <input name="txtDate" type="text" />   <a href=&q...

Command+W with one window opened; not saving pages quitting when just one page opened
Name: miu Product: Firefox Summary: Command+W with one window opened; not saving pages quitting when just one page opened Comments: I've just download the 3.0.8 update. With Mac I used to close all windows with command+w. With the new version I cannot do this anymore. Furthermore, if I quit the application with one window open, Firefox is not asking me anymore if I want to save the page and quit, so I can refind that page when I'll open Firefox again Browser Details: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.0.8) Gecko/2009032608 Firefox/3.0.8 From U...

OPEN NEW WINDOW USING window.open
Hi, can any eagle eyed geniuses spot what I'm doing wrong here? It's doing my nut! I'm simply trying to call a new page in a new window that I want to control the size, etc. I've tried two different ways - one from within my code behind and the other triggered by a LinkButton command action. Both do absolutely nothing. Please help... Private Sub InfoClick1(ByVal pSiteCode) Response.Write("<script>window.open('siteinfo.aspx?sitecode='" & pSiteCode & "','Info','left=20,top=20,height=500,width=850,toolbar=no,status=no,resizable=1,scrollbars=no')</script>") End Sub +...

automatic redirect to other page using window.open from client side when page is fully posted back
 hi,     i am experiencing  a problem in <asp:history runat="server"/> control.in order to maintain back and forward button concept i am using <asp:history control.it works fine but the problem is when i redirect to other page using response.redirect ("") i loss my all history points and when i click on back/forward button i am redirected to last full rendered page not to partially updated by ajax.second thing is i cant use server.transfer("") ,since it will not change URL. Third thing is i cant use scriptmanager .registerc...

Modal Popup window opens new window when form posted
I am having trouble with modal dialog.  I have a web page PopupTestParent.aspx and popup.aspx.  When I click button on popupTestParent.aspx, it opens modal dialog as exptected, when I click button on Popup.aspx, and form gets posted, it opens a new window, instead of using same window as the form.  code for both pages is given below.. Any clue, how to get over this? <%@ Page Language="C#" AutoEventWireup="true" CodeFile="PopupTestParent.aspx.cs" Inherits="PopupTestParent" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...

Using Windows Forms control in an HTML page
Hi,  I have made a simple web page that displays both a textbox and a control with this code.   <asp:textbox id="TextBox1" style="Z-INDEX: 101; LEFT: 112px; POSITION: absolute; TOP: 232px" runat="server" Width="96px"></asp:textbox> <OBJECT id="CCTLiteWebControl" height="280" width="500" classid=http://localhost/cctlitewebref/webref/Debug/CCTLiteWebControl.dll#CCTLiteWebControl.ReferenceCtrl VIEWASTEXT></OBJECT> It displays just fine and I can use the control. How do I make a value ...

prevent opening a new window in modal window using content page
Hi, I have a content page with a button and when I click it, I am trying to open a modal window using javascript:showmodaldialog (this is a normal aspx page, I mean not a content page). In the modal window. I have a asp button and when I click the button,I am trying to do some validation and the close the modal window. what is h appening is, when I  click the button my code is executing and after that a webpage is opening again and the cotents which are in modal window are displayed in the webpage. how to avoid this. <cotent>  <asp:button id="btn" text=&...

window.modal vs window.open, which to use and how to use?
Hi, I am opening a child window through javascript with window.modal but the problem is when i click a button or link it opens another page with respect to that link, i want to open that page in same child window. when i used window.open the parameters like location scroll bar etc were made false but it had no effect on the child window, using window.modal is fine as far as these paremeters are concerned but the problem is same as i told you people earlier that it opens a third page. how to solve the problem thanx in advance I use modals a lot and they work well. Place <base...

Use UpdateProgress control in the popup window before accessing the next page in original window
Hello. What I intended to do is that I've used the UpdateProgress control in the Popup window and when a button is clicked to go to the next page in the Original window, the Popup window will close and display the page in the Original window. But before displaying the page in the Original window, I want the UpdateProgress control in the Popup window to show a message to let the user know that it is now going to the next page then close the Popup window.The problem now is that I do not know how to combine the 2 actions together into the same button that is being clicked to disp...

If more than one ff windows are open, which window an outside link would open to?
I have decided to keep two ff windows open, one having just my work related sites open, and the other having time pass/ waste thinggies like fb, orkut, sudoku... :-) Now, if I click any link from outside of these windows (say, from TB, or some help manual or about screen of some software). to which window would my that outside link get open to? is there any logic behind this? Can we choose that a particular link gets opened to a particular window only? how? Thanks. -- Rawat On 10/22/2012 11:07 AM, V S Rawat gmoz wrote: > I have decided to keep two ff windows open...

window.opener.document.forms['Form1'].submit()
hello everybody i have a table populated in asp.net with clickable rows. when the client click on a row it opens a popup windows form, that let him change some data (for example his name). when he click Change button, i update my database at i close the popup window and i refresh the parent page protected void btnSave_Click(object sender, EventArgs e) { if (!changeName()) return; Response.Write("window.opener.document.forms['Main'].submit();"); Response.Write("window.close();&quo...

Web resources about - More than one page posts using window.opener.window.document.forms[0].submit(); - asp.net.navigation-controls

Killian documents controversy - Wikipedia, the free encyclopedia
The provider of the documents, Lt. Col. Bill Burkett , claims to have burned the originals after faxing copies to CBS. CBS News producer Mary ...


Document: Letter from City Schools ahead of Freddie Gray case verdict
Open as PDF Need a gift? Give 6 months of unlimited digital access for $39. The Baltimore Sun Document: Letter from City Schools ahead of Freddie ...

Officials investigate ISIS faking entry documents
Boston Herald Officials investigate ISIS faking entry documents Boston Herald U.S. intelligence officials fear ISIS terrorists are spreading ...

Prince William ‘occasionally receives copies of confidential cabinet documents’
... a kerfuffle in the British press about William and what he has access to. It’s well-known that the Queen receives extensive government documents ...

Laquan McDonald court documents show teen hoped for better life
Chicago Tribune Laquan McDonald court documents show teen hoped for better life Chicago Tribune Photos: Follow developments in the 2014 fatal ...

Understanding ISIS: Leaked document reveals nation-building plans
A state-building manual for Islamic State administrators confirms the complexity and breadth of the group's efforts to create a functioning state, ...

Here Are The Documents Showing Massive Whistleblower Retaliation At Phoenix VA
'Incredibly VA still hasn’t disciplined these officials for their retaliatory behavior'

Chris Christie claimed he barred Syrian refugees, but there's no such documents to be found
In November, during the peak of Republican bellicosity toward, sigh, war refugees, New Jersey governor and traffic manager Chris Christie declared ...

Leaked documents trial: Vatican court OKs Pope Francis's no. 2 as defense witness
Leaked documents trial: Vatican court OKs Pope Francis's no.

Resources last updated: 12/21/2015 5:03:20 AM