C
cindy
I have a procedure long running in C# asp.net 2003 app
I need to show iframe with just a graphic (bouncing ball) inside the
procedure and before end of procedure close the window
I know there are more complicated solutions for a progress bar but I haave
spent 2 weeks and I cannot get them to work
I have a test form, click a button enter a procedure show the iframe and
with click of second button set parent div with iframe in it display to none
show then none
I cannot understand why on the close I get the javascript error
Microsoft JScript runtime error: Object required
on line
<script language ="javascript">
parent.document.getElementById("cont").style.display = "none";
which is the script that executes in close
the code behind is
protected void Page_Load(object sender, EventArgs e)
{
AddClientScript();
}
protected void AddClientScript()
{
const string scriptName = "CALL_POPUP";
StringBuilder sb = new StringBuilder("");
sb.Append("\n<script language =\"javascript\">");
sb.Append("\nlast_id = \"\";");
sb.Append("\nfunction frame_pop(id, oLeft, oTop, oPage)");
sb.Append("\n{");
sb.Append("\nvar mystr = window.showModalDialog('Popframe.aspx');");
sb.Append("\nif (undefined != mystr)");
sb.Append("\n{");
sb.Append("\ndocument.getElementById(\"my_iframe\").style.width =
parseInt(document.getElementById(\"cont\").style.width);");
sb.Append("\ndocument.getElementById(\"my_iframe\").style.height =
parseInt(document.getElementById(\"cont\").style.height);");
sb.Append("\n}");
sb.Append("\nif (id != last_id) {");
sb.Append("\ndocument.getElementById(\"cont\").style.display =
\"block\";");
sb.Append("\ndocument.getElementById(\"cont\").style.left = oLeft;");
sb.Append("\ndocument.getElementById(\"cont\").style.top = oTop;");
sb.Append("\nwindow.frames[\"my_iframe\"].location = oPage;");
sb.Append("\nlast_id = id;");
sb.Append("\n}");
sb.Append("\nelse {");
sb.Append("\ndocument.getElementById(\"cont\").style.display =
\"none\";");
sb.Append("\nlast_id = \"\";");
sb.Append("\n}");
sb.Append("\nreturn false;");
sb.Append("\n}");
sb.Append("\n</script>");
if (!ClientScript.IsClientScriptBlockRegistered(scriptName))
//ClientScript.RegisterStartupScript(typeof(Page), scriptName,
sb.ToString());
ClientScript.RegisterClientScriptBlock(typeof(Page), scriptName,
sb.ToString());
}
public static void OpenProgressBar(System.Web.UI.Page Page)
{
StringBuilder sbScript = new StringBuilder();
sbScript.Append("\n<script language =\"javascript\">");
sbScript.Append(" \n");
sbScript.Append("\nvar newwindow = window.open('page1.aspx', 'name',
'height=200,width=300,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');");
sbScript.Append("\n</script>");
Page.RegisterClientScriptBlock("OpenProgressBar",
sbScript.ToString());
}
public static void CloseProgressBar(System.Web.UI.Page Page)
{
StringBuilder sbScript = new StringBuilder();
sbScript.Append("\n<script language =\"javascript\">");
sbScript.Append("\nparent.document.getElementById(\"cont\").style.display =
\"none\";");
sbScript.Append("\n</script>");
Page.RegisterClientScriptBlock("CloseProgressBar",
sbScript.ToString());
}
protected void Button1_Click(object sender, EventArgs e)
{
BindData();
}
protected void BindData()
{
OpenProgressBar(this.Page);
}
protected void BindData2()
{
CloseProgressBar(this.Page);
}
protected void Button2_Click(object sender, EventArgs e)
{
BindData2();
}
the form is
<form id="form1" runat="server">
<div runat="server" id="cont"
style="position:absolute;left:300px;top:200px;width:300px;height:140px;display:none;border:1px solid #000000">
<div runat="server" id="pop"
style="text-align:center;background-color:#FFFFFF"> </div>
<iframe id="my_iframe" name="my_iframe" src="" frameborder="0"></iframe>
</div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="open" />
<asp:Button ID="Button2" runat="server" Text="close"
onclick="Button2_Click" />
</form>
I need to show iframe with just a graphic (bouncing ball) inside the
procedure and before end of procedure close the window
I know there are more complicated solutions for a progress bar but I haave
spent 2 weeks and I cannot get them to work
I have a test form, click a button enter a procedure show the iframe and
with click of second button set parent div with iframe in it display to none
show then none
I cannot understand why on the close I get the javascript error
Microsoft JScript runtime error: Object required
on line
<script language ="javascript">
parent.document.getElementById("cont").style.display = "none";
which is the script that executes in close
the code behind is
protected void Page_Load(object sender, EventArgs e)
{
AddClientScript();
}
protected void AddClientScript()
{
const string scriptName = "CALL_POPUP";
StringBuilder sb = new StringBuilder("");
sb.Append("\n<script language =\"javascript\">");
sb.Append("\nlast_id = \"\";");
sb.Append("\nfunction frame_pop(id, oLeft, oTop, oPage)");
sb.Append("\n{");
sb.Append("\nvar mystr = window.showModalDialog('Popframe.aspx');");
sb.Append("\nif (undefined != mystr)");
sb.Append("\n{");
sb.Append("\ndocument.getElementById(\"my_iframe\").style.width =
parseInt(document.getElementById(\"cont\").style.width);");
sb.Append("\ndocument.getElementById(\"my_iframe\").style.height =
parseInt(document.getElementById(\"cont\").style.height);");
sb.Append("\n}");
sb.Append("\nif (id != last_id) {");
sb.Append("\ndocument.getElementById(\"cont\").style.display =
\"block\";");
sb.Append("\ndocument.getElementById(\"cont\").style.left = oLeft;");
sb.Append("\ndocument.getElementById(\"cont\").style.top = oTop;");
sb.Append("\nwindow.frames[\"my_iframe\"].location = oPage;");
sb.Append("\nlast_id = id;");
sb.Append("\n}");
sb.Append("\nelse {");
sb.Append("\ndocument.getElementById(\"cont\").style.display =
\"none\";");
sb.Append("\nlast_id = \"\";");
sb.Append("\n}");
sb.Append("\nreturn false;");
sb.Append("\n}");
sb.Append("\n</script>");
if (!ClientScript.IsClientScriptBlockRegistered(scriptName))
//ClientScript.RegisterStartupScript(typeof(Page), scriptName,
sb.ToString());
ClientScript.RegisterClientScriptBlock(typeof(Page), scriptName,
sb.ToString());
}
public static void OpenProgressBar(System.Web.UI.Page Page)
{
StringBuilder sbScript = new StringBuilder();
sbScript.Append("\n<script language =\"javascript\">");
sbScript.Append(" \n");
sbScript.Append("\nvar newwindow = window.open('page1.aspx', 'name',
'height=200,width=300,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');");
sbScript.Append("\n</script>");
Page.RegisterClientScriptBlock("OpenProgressBar",
sbScript.ToString());
}
public static void CloseProgressBar(System.Web.UI.Page Page)
{
StringBuilder sbScript = new StringBuilder();
sbScript.Append("\n<script language =\"javascript\">");
sbScript.Append("\nparent.document.getElementById(\"cont\").style.display =
\"none\";");
sbScript.Append("\n</script>");
Page.RegisterClientScriptBlock("CloseProgressBar",
sbScript.ToString());
}
protected void Button1_Click(object sender, EventArgs e)
{
BindData();
}
protected void BindData()
{
OpenProgressBar(this.Page);
}
protected void BindData2()
{
CloseProgressBar(this.Page);
}
protected void Button2_Click(object sender, EventArgs e)
{
BindData2();
}
the form is
<form id="form1" runat="server">
<div runat="server" id="cont"
style="position:absolute;left:300px;top:200px;width:300px;height:140px;display:none;border:1px solid #000000">
<div runat="server" id="pop"
style="text-align:center;background-color:#FFFFFF"> </div>
<iframe id="my_iframe" name="my_iframe" src="" frameborder="0"></iframe>
</div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="open" />
<asp:Button ID="Button2" runat="server" Text="close"
onclick="Button2_Click" />
</form>