[RESOLVED]capture iframe json response in view

I have one iframe define in page , having 2 text box and submit button after clicking on submit button it get validate input request and send json format response.

json response format

code: 400

merg:3249874

desc:test

here, how i can capture/pass code value to my main page.

thanks in advance

 

thanks for reply.

there is one limitation here, i can’t make any change in  ifrmae code & my task it to only consume the json generated response and pass some fileds to

parent form

thanks

Hi

kirank28

there is one limitation here, i can’t make any change in ifrmae code & my task it to only consume the json generated response and pass some fileds to parent form.

From your description, I suppose there is a submit button in the iframe, when you click the submit button, you want to transfer data to parent page. If that is the case, the simple way is that using the following code in the submit button click event.

response.redirect("MainPage.aspx?data="+data);

Then, in the MainPage onload event, get the data by using Request.QueryString method.

Here is a similar thread, you could refer to it.

http://forums.asp.net/t/1852758.aspx?how+retrive+values+from+one+page+to+another+page+inside+iframe

As you said, you can’t make any change in iframe. Here is a sample about get the content of an Iframe in Javascript, perhaps it can help you.

</head>
<body>
<script type="text/javascript">
function getContentFromIframe(iFrameName)
{
    var myIFrame = document.getElementById(iFrameName);
    var content = myIFrame.contentWindow.document.body.innerHTML;
 
    alert('content: ' + content);    
 
    content = 'The inside of my frame has now changed';
    myIFrame.contentWindow.document.body.innerHTML = content;
}
</script>
</iframe>
<a href="#" onclick="getContentFromIframe('myIframe')">Get the content</a>
</body>
</html>

Best Regards

thanks for reply  ,seems like your example is incomplete , could you please correct it?

Hi kirank28,

As indicated in my previous reply, the sample will get the content of an iframe. If you want to get the textbox value, you need to retrieve the content.

For more details, you could refer to this links.

http://roneiv.wordpress.com/2008/01/18/get-the-content-of-an-iframe-in-javascript-crossbrowser-solution-for-both-ie-and-firefox/

Besides, here is a similar thread, you could refer to it.

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_28096073.html

Best Regards

Hi kirank28,

kirank28

how i can capture/pass code value to my main page.

From your description, I suggest you try to use session variables.

Here is a similar thread, you could refer to it.

http://forums.asp.net/t/1852758.aspx?how+retrive+values+from+one+page+to+another+page+inside+iframe

Best Regards,
Dillion

Leave a Reply