Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > progress indicator long running proc NO Button click

Reply
Thread Tools

progress indicator long running proc NO Button click

 
 
cindy
Guest
Posts: n/a
 
      06-30-2009

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.displ ay = "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.w idth);");
sb.Append("\ndocument.getElementById(\"my_iframe\" ).style.height =
parseInt(document.getElementById(\"cont\").style.h eight);");
sb.Append("\n}");
sb.Append("\nif (id != last_id) {");
sb.Append("\ndocument.getElementById(\"cont\").sty le.display =
\"block\";");
sb.Append("\ndocument.getElementById(\"cont\").sty le.left = oLeft;");
sb.Append("\ndocument.getElementById(\"cont\").sty le.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\").sty le.display =
\"none\";");
sb.Append("\nlast_id = \"\";");
sb.Append("\n}");
sb.Append("\nreturn false;");
sb.Append("\n}");
sb.Append("\n</script>");
if (!ClientScript.IsClientScriptBlockRegistered(scrip tName))
//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,st atus=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;widt h: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>





--
cindy

 
Reply With Quote
 
 
 
 
Andrew Morton
Guest
Posts: n/a
 
      06-30-2009

"cindy" wrote
> 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.displ ay = "none";
> which is the script that executes in close


In your code where you're generating the JavaScript, you need to use
cont.ClientId instead of "cont":

sb.AppendFormat("\ndocument.getElementById(\"{0}\" ).style.display =
\"block\";", cont.ClientId);

because when you put runat="server" in the div, it alters the ID when it
renders the HTML. Just look at the source and you'll see what I mean.

Andrew

 
Reply With Quote
 
 
 
 
cindy
Guest
Posts: n/a
 
      06-30-2009

Still get object not found, I do not need runat for div so I simplifed the form

<form id="form1" runat="server">

<div id="cont"
style="position:absolute;left:300px;top:200px;widt h:300px;height:140px;display:none;border:1px solid #000000">
<div 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 commented out the line in the close created by javascript to use your
suggestion but maybe I have syntax wrong


//sbScript.Append("\nparent.document.getElementById( \"cont\").style.display
= \"none\";");

sbScript.AppendFormat("\ndocument.getElementById(\ "cont.ClientId\").style.display = \"none\";");

I looked in the source created below and I see <div id="cont"


<script type="text/javascript">

//Realised by Apachejeff
//www.huntingground.freeserve.co.uk

last_id = ""
function frame_pop(id, oLeft, oTop, oPage) {
document.getElementById("my_iframe").style.width =
parseInt(document.getElementById("cont").style.wid th)
document.getElementById("my_iframe").style.height =
parseInt(document.getElementById("cont").style.hei ght)
if (id != last_id) {
document.getElementById("cont").style.display = "block"
document.getElementById("cont").style.left = oLeft
document.getElementById('cont').style.top = oTop
window.frames["my_iframe"].location = oPage

setTimeout('document.getElementById("headertxt").i nnerHTML=window["my_iframe"].document.title', 200)
last_id = id
}
else {
document.getElementById('cont').style.display = "none"
last_id = ""
}

return false


}
</script>


<body>
<form name="form1" method="post" action="index.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKMTg3NjE0NDI3MmRk6v0m9Bx5KGf3D6sGA3/cnza95QY=" />
</div>


<script language ="javascript">

var newwindow = window.open('page1.aspx', 'name',
'height=200,width=300,toolbar=no,directories=no,st atus=no,menubar=no,scrollbars=no,resizable=no');
</script>
<div>

<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEWAwKC8enKDAKM54rGBgK7q7GGCKC1w3Vx0StuMtnTanzYGpz KBaEi" />
</div>

<div id="cont"
style="position:absolute;left:300px;top:200px;widt h:300px;height:140px;display:none;border:1px solid #000000">
<div id="pop" style="text-align:center;background-color:#FFFFFF"> </div>

<iframe id="my_iframe" name="my_iframe" src="" frameborder="0"></iframe>

</div>
<input type="submit" name="Button1" value="open" id="Button1" />
<input type="submit" name="Button2" value="close" id="Button2" />
</form>
</body>
</html>

here is the codebehind that creates the javascript see above in source

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,st atus=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.AppendFormat("\ndocument.getElementById(\ "cont.ClientId\").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();
}




--
cindy


"Andrew Morton" wrote:

> "cindy" wrote
> > 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.displ ay = "none";
> > which is the script that executes in close

>
> In your code where you're generating the JavaScript, you need to use
> cont.ClientId instead of "cont":
>
> sb.AppendFormat("\ndocument.getElementById(\"{0}\" ).style.display =
> \"block\";", cont.ClientId);
>
> because when you put runat="server" in the div, it alters the ID when it
> renders the HTML. Just look at the source and you'll see what I mean.
>
> Andrew
>
>

 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      06-30-2009

"cindy" wrote
> Still get object not found, I do not need runat for div so I simplifed the
> form


Can you install Firefox and use the Firebug add-on to investigate the DOM?

Other examples I've seen (e.g.
http://www.sitepoint.com/forums/showthread.php?t=177654) suggest what you're
doing is right.

Andrew

 
Reply With Quote
 
cindy
Guest
Posts: n/a
 
      06-30-2009

I have to install Firefox on another machine and move the application and
install .net and add the addon to debug?

How about any link to any demo using the show and close iframe using
javascript in the code behind
--
cindy


"Andrew Morton" wrote:

> "cindy" wrote
> > Still get object not found, I do not need runat for div so I simplifed the
> > form

>
> Can you install Firefox and use the Firebug add-on to investigate the DOM?
>
> Other examples I've seen (e.g.
> http://www.sitepoint.com/forums/showthread.php?t=177654) suggest what you're
> doing is right.
>
> Andrew
>
>

 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      07-01-2009

"cindy" wrote
> I have to install Firefox on another machine and move the application and
> install .net and add the addon to debug?


Is there any reason not to install Firefox on your dev machine? In VS, you
can right-click on an .aspx file and choose which browser to open it with.
Or if you run the app in IIS (this may be another can of worms) instead of
the web server that comes with VS, you could easily access it from another
PC. It's often a good idea to check web sites in other browsers anyway,
unless you have a defined target audience.

> How about any link to any demo using the show and close iframe using
> javascript in the code behind


I haven't seen one, but as long as your generated JS looks the same as the
other googleable communicating-from-an-iframe-to-its-parent scripts, I don't
see why it won't work - unless there's something awry with where in the DOM
you should be pointing it to or there's some security thing in the browser
preventing communication out from the iframe , but I thought the latter only
applied to iframe content from a different domain.
http://www.google.com/#hl=en&q=iframe+parent+javascript

Does anyone else want to chime in?

Andrew

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      07-01-2009
On Jul 1, 3:32*am, "Andrew Morton" <(E-Mail Removed)>
wrote:
> "cindy" wrote
>
> > I have to install Firefox on another machine and move the application and
> > install .net and add the addon to debug?

>
> Is there any reason not to install Firefox on your dev machine? In VS, you


is there any reason to install Firefox to debug javascript?

You can do it using IE and VS.NET IDE
http://www.google.com/search?q=javascript+debug+ie
 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      07-01-2009
On Jun 30, 10:49*pm, cindy <(E-Mail Removed)> wrote:
> 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.displ ay = "none";
> *which is the script that executes in close
>


What version of ASP.NET do you use?

Simply open source code window in IE (right click - view source) and
check if you have <div id=cont> there. It might be that you have no
that div, or it has another id. You specified it as a server control
(runat=server). Do you really need it? If yes, instead of
document.getElementById('cont') use document.getElementById('<
%=cont.ClientID%>').

<%=cont.ClientID%> injects client id of the server control.

If you still has a problem, post the rest of the code. For example, it
is not clear where do you call frame_pop from.

Hope this helps
 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      07-01-2009
Alexey Smirnov wrote:
> is there any reason to install Firefox to debug javascript?


Well, as far as I can tell, it appears that the problem is accesing the div
with id="cont" from the iframe, and the Firebug add-on makes it simple to
explore the DOM. Also, if there was a bug in IE, it might work as-is in FF,
so a work-around could be devised (although I saw no google results
suggesting such a bug).

Andrew


 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      07-01-2009
On Jul 1, 10:46*am, "Andrew Morton" <(E-Mail Removed)>
wrote:
> Alexey Smirnov wrote:
> > is there any reason to install Firefox to debug javascript?

>
> Well, as far as I can tell, it appears that the problem is accesing the div
> with id="cont" from the iframe, and the Firebug add-on makes it simple to
> explore the DOM. Also, if there was a bug in IE, it might work as-is in FF,
> so a work-around could be devised (although I saw no google results
> suggesting such a bug).
>
> Andrew


Well, I use FF to debug, but because I already have it. I totally
agree that there are some add-ons which make debug really simple, but
seeing "Object required on line XX" in IE, I think you have clear
message what is wrong. I already posted some hints on how to get the
problem solved
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
progress indicator window with Stop button Composer Java 17 02-27-2009 05:53 AM
Having compilation error: no match for call to (const __gnu_cxx::hash<long long int>) (const long long int&) veryhotsausage C++ 1 07-04-2008 05:41 PM
[EJB] Long lasting session bean - how to implement progress indicator? pljosh.mail@gmail.com Java 0 12-13-2006 12:55 AM
Convert VB.NET to TSQL PROC & Reference a Proc from another Proc David Lozzi ASP .Net 3 06-01-2005 06:35 PM
HttpHandler Progress Indicator Dale Ragan via .NET 247 ASP .Net 1 08-06-2004 08:45 PM



Advertisments