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; ivar 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:
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; ivar 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; ivar 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:
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 |
![]() |
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 |
![]() |