Need help with IFrame callback

P

pbd22

Hi. I am not sure if this is clearly an ASP.NET question but every
time I post to either C# or (in many cases) JavaScript, I am told to
post here. So, here goes...



Hi.

I have an iframe on my page:

<iframe id="target_frame" src="" style="border:0px; width:0px; height:
0px"></iframe>

The form tag points to it:

<form enctype="multipart/form-data" id="fileUploadForm"
name="fileUploadForm" action="picupload.aspx" method="post"
target="target_frame">

And the submit button starts a file upload via the iframe:

<input id="submit" type="submit" value="upload" />

In the picupload.aspx.cs file, I have a method that returns dynamic
data. I then send it to the client:

message = data;
Response.Write(String.Format("<script language='javascript' type='text/
javascript'>window.parent.handleResponse('{0}');</script>", message));

On the client, I have a response handler:

function handleResponse(msg) {
document.getElementById('statusDiv').innerHTML = msg;
}

My intent is to see the msg value change for each uploaded file but I
never see anything appear in statusDiv, let alone dynamically changing
messages.

Can somebody please help??
 
A

Alexey Smirnov

Hi. I am not sure if this is clearly an ASP.NET question but every
time I post to either C# or (in many cases) JavaScript, I am told to
post here. So, here goes...

Hi.

I have an iframe on my page:

 <iframe id="target_frame" src="" style="border:0px; width:0px; height:
0px"></iframe>

The form tag points to it:

<form enctype="multipart/form-data" id="fileUploadForm"
name="fileUploadForm" action="picupload.aspx" method="post"
target="target_frame">

And the submit button starts a file upload via the iframe:

<input id="submit" type="submit" value="upload" />

In the picupload.aspx.cs file, I have a method that returns dynamic
data. I then send it to the client:

message = data;
Response.Write(String.Format("<script language='javascript' type='text/
javascript'>window.parent.handleResponse('{0}');</script>", message));

On the client, I have a response handler:

 function handleResponse(msg) {
        document.getElementById('statusDiv').innerHTML = msg;
  }

My intent is to see the msg value change for each uploaded file but I
never see anything appear in statusDiv, let alone dynamically changing
messages.

Can somebody please help??

Add to the handleResponse function some debug messages such as

alert(document.getElementById('statusDiv'));
alert(msg);

and see if you get something there.

First alert is to check if handleResponse was executed and 'statusDiv'
container was found, second alert is to see its message string.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top