Check value inside IFrame before post back - javascript

I am using an IFrame in my WebForm aspx page. I fill in the data in the IFrame, IFrame has the auto post when all data is filled.
I click the Server Side button that posts the page back to the server, I need to check a certain value in of the IFrame before I post back in the page.
I have added on client click javascript function to server side button to investigate if the value is populated for the element inside IFrame.
I get cross-origin error. Is there a way to check/wait for the iframe to populate the element inside it before I trigger my server side code ?

Related

PHP header with AJAX loaded pages?

I currently have it set up so that to navigate to various pages you click links on index.php, which then load into the content box of index.php.
I currently have a form on one of those pages that once submitted, I would like to redirect to the index.php page. But instead of displaying the default content on index.php, I'd like to specify the page loaded into the content box.
Is there a way to do this using a header? eg. header('Location: index.php#<contentboxpagehere>'); ??
Thanks!
So if I have understood correctly, you have a form and after a successful submission you want to redirect to the front page and display the right output message with an AJAX call in your defined page container.
You can achieve that in many ways. Keeping it simple and PHP you can do that with either a POST or GET request on the index page passing the container id you want to call in your front page AJAX container.
Using GET, pass URL parameter like: index.php?cbpId=success
Get the $_GET['cbpId'] and load the right content on the front page.

Javascript displays div is gone after postback

I have a page that has a button that displays the contents of a div with javascript. I have a ASP.net validator control that does a postback. If I step though my javascript in firebug the page still has the div visible, and if i just let the page run normally the javascript makes the div visible for a second then the postback resets the visibility to off when it reloads. How can I stop this from happening?
Thanks!
When making the DIV visible set the value of a hidden field that will be persisted in the post back. Read that value in the Load and determine if you need to make that same DIV visible server side.
When the post back occurs the entire page is rebuilt and so the things that changed client side, disconnected from the server, can't just simply be persisted.

How does Button Click fire httphandler Asp.net

I have a webform application.
The page has a from which contains a set of textboxes and one ASP:FileUploader.
A button called "Upload" will uploaded the file separately from saving the whole form.
I set up a httpHandler to upload files in chunks, and it should be fired after user click "Upload".
They only way I worked out is set the PostBackURL attribute in the "Upload" button. e.g.
PostBackURL = ".upload"
which maps to the httpHandler's Path.
But my problem is "PostBackURL" is a Redirect , It does fire the httpHandler but it will direct to ".upload" page (which its content is empty ) , and user lost information in other textboxes.
So what is the best way to fire a httpHandler and let the browser stay in the current page? Is iframe the only option?
To post to a hidden <iframe> element, the general pattern that I've always followed is:
Set the target of the form to point to the name of the <iframe> element. (Generally I give the <iframe> the same "name" and "id" value out of old habit; it may not be necessary.)
Post the form. That'll initiate the HTTP transaction but it won't blow away the page that the form is on.
The response to the POST should be a page with nothing on it (or almost nothing) except some JavaScript. That code can talk to the parent page to tell it either that there was a problem with the file upload (like, you wanted an image file, and the file posted was text) or that the upload succeeded. In either case, the parent page can update itself with either an error message or some success message.
At that point, the form "target" attribute can be cleared.
When the <form> is to be posted "normally", you might want to disable the file <input>. (Depends on your situation.

Dynamically change the URL of a Facebook Send Button

I am trying to dynamically change the URL of a Facebook Send button with Javascript, but I have had no success so far.
I have a page set up with a few inputs, and I would like the URL of the send button to take the fields value as parameters before it sends it. The problem is when I add the send button to the page, it generates the iframe code inside and even if I modify the href parameter later on, the iframe still keeps the original link in. I guess the solution would be to refresh the content of the send button somehow or add it after page load, once the fields have been completed, but I couldn't figure it out.
Thanks for your help.
You can try using the iFrame version of the like button instead the XFBML version. The like button can be post-loaded into the page after the form submission, via an AJAX call, in which you have passed the data filled up in the form.
You can't do this. Javascript can't be used to control an iFrame on a different domain than yours. This is due to the Same Origin Policy.
What you can do is change the parameters on you send button xfbml tag and then call FB.XFBML.parse(); so the button uses the new parameters.

Postback from client-generated links (AJAX)

I have AJAX functionality on my page which creates anchor tags. I know I can fabricate a postback for these links by setting the href attribute to javascript:__doPostBack('ControlID','SomeArgument')
How do I execute server code based on this fake postback for 'controls' that are created on the client side?
You need to implement IPostBackEventHandler on your page.

Categories

Resources