Showing posts with label browser. Show all posts
Showing posts with label browser. Show all posts

Wednesday, March 28, 2012

Why Response.Redirect() opens up a new browser window in AJAX?

I have an AJAX enabled page displayed in amodal dialog, When I click on a button that has a Response.Redirect() code, a new browser window gets opened, which is weird and not the behavior that I expect.

I should note that this page worked properly before adding the AJAX related stuff.

I highly appreciate any insight into this problem.

try use server.transfer


I had already tried the Server.Transfer but I got a client side alert: "Sys.WebForms.PageRequestManagerParserErrorException: The message recieved from the server could not be parsed,..."
Try to navigate to next page in Javascript instead of on Server side. I think this can solve the issue.

hello.

i think the problem is that submitting a page on a popup will open another window by default. you can workaround this by adding an iframe to your popup window which loads the page you need.


Thanks, I think the only workaround to my problem was to use the IFrame in the modal window, but still, I'm wondering why the use of Server.Transfer() caused the error in AJAX, and, why the Response.Redirect() would open up a new window, was I missing somthing or it's just the way AJAX works!

May I ask that Response.Redirect is logical/possible at all during a partial postback (for example in an updatepanel's button click event)?!

Simply move that specific button which yield Response.Redirect outside of the updatepanel, maybe it helps.


Yes, the button which yielded the Response.Redirect() or Server.Transfer() for that matter, was inside the UpdatePanel, I moved it outside the UpdatePanel and my problem was solved. Actually the UpdatePanel was inside a Container UserControl, I think I should make use of UpdatePanel more narrowly focused.

Thank you very much indeed.


response.redirect will be correctly interpreted by the ajax platform. you can check this by using ?a "normal" page. the problem that was happening here was related with modal dialogs and the issue described is not an ajax problem.

server.transfer won't work correctly with ajax and shouldn't be used from controls placed inside the updatepanel. this is understandable because partial postbacks expect to receive a predefined message from the server and whe you do a server.transfer you end up retunring a new page to the user which doesn't conform to the expected message.

So response.redirect works with ajax.

If ajax open the redirected page via javascript (maybe using window.open( ... ) ), that can be a problem.

Modern tabbed browsers are configurable how to treat popup pages from normal links or from javascript (new window, same window, new tab, disable totally javascript popups etc.)

I recommend for Robert to try the page in firefox, and play with advanced firefox settings (type about:config in the address bar, and play with "browser.link.open_newwindow.restriction" and similar settings, you can google for help how it works)

ps:

If the button must be in the updatepanel, maybe it is possible to register a script in the server side which open the new window by javascript (a more controlled way.)


I am also running into this problem and am unable to place the control outside of the Update Panel. I am not clear as to how an IFrame would be implemented. Is it meant that an IFrame should be used in place of the AJAX update panel or in addition to? How would this implementation work specifically?

Thanks for any information in advance.


MaybeScriptManager.RegisterPostBackControl could be used to eliminate this problem in some cases.

So leave your button (which has the codebehind redirect logic) in the updatepanel, but use the RegisterPostBackControl method so it will cause a full normal postback. That way you have a normal redirect, not the ajax client side redirect.


Thanks for the responses.

I did try the following on the control that is being clicked to fire the Redirect:

ScriptManager1.RegisterPostBackControl(this.testButton);

Unfortunately, this still launches a new window during the redirect.

Does anyone have any other ideas as to how i can do this? I would be open to attaching some javascript to the button in order to perform the redirect, however, I have already tried adding the following with no success:

ScriptManager.RegisterClientScriptBlock(this.buttonTest,this.buttonTest.GetType(),"Redirect","window.location = 'http://www.testpage.com'",true);


jriell:

I have already tried adding the following with no success:

ScriptManager.RegisterClientScriptBlock(this.buttonTest,this.buttonTest.GetType(),"Redirect","window.location = 'http://www.testpage.com'",true);

If you choose that way (custom client side redirect), I recommend the following to try:

Put a regular input button, link etc. in the updatepanel, for example:

<input type="button" value="test" onclick="window.location.replace( 'http://www.testpage.com' );" />

If that works, try the script withthe RegisterClientScriptBlock stuff.

Why XmlHTTP?

Have we looked at standard DHTML alternatives to XmlHTTP? I've never used it in my AJAX apps because of browser compatibility and security dialogs cross-domain. I understand using it to connect to non-Atlas web services, but an Atlas client to Atlas web service could asychronously request data post-page load by requesting script - e.g. I could call the web service like "myservice.asmx/js?param1=foo¶m2=bar".

You are right that XmlHTTP can have browser compatibility issues, which is why a client framework like Atlas is useful. When you use Atlas, you never directly use XmlHTTP. Instead, you use Atlas abstractions built on top of it that have the necessary logic to make it work in most browsers.
I'm not sure I understand the alternative that you're suggesting. Another method that is sometimes used it to make the request into a (hidden) iframe, and get the data from there. Is that what you are referring to? Note that doing this will hit the same cross-domain limitations as using XmlHTTP (this is by design for security reasons).
David

Thanks, I understand the user doesn't use XmlHTTP directly. But the underlying layers use it exclusively (at least from my cursory examination of AtlasCore.js), limiting the browser support.
Yes, that is the technique I am referring to. It does not have cross-domain limititations (there's no reason I can't include a script from another domain - by placing the reference in my page, I am allowing that script to run in my domain). If you're interested I can point you to a live demo application on one domain requesting data from another domain (asynchronously, post-page load, no-xmlhttp).
Jim


Hi Jim,
If a page has an iframe, it can navigate that iframe to any URL. However, it cannot access the data inside that frame unless it lives in the same domain, due to cross frame scripting restrictions:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/xframe_scripting_security.asp
But maybe your are talking about something different?
thanks,
David
Does XmlHTTP restrict us to REST-style interactions with all the pre-knowlege that requires or can we use XmlHTTP for compositional discoverable SOAP? If so, I can easily imagine AJAX style pages that will need to pull data from many many sites. Imagine, for example, an enterprise window to embedded control systems accessible by SOAP such as available from
BACnet under BACnet-XML
LON using iLON 100
Tridium using the new Niagra framework
In each of these cases you are discussing a single interface pointing to multiple exposed data sources. Lets move the bar higher, then, to also pull vector XML (say SVG) from some sort of drawing room
If I have all these sources in my trusted sites, why shouldn't I be able to cross-script across them?
Hello.
I'm a much interesting in your live demo. If it possible can you send it to me at mrorbit [at] pochta.ru.
Thank you in advance.
Another method I have used is loading a script with an IE:DOWNLOAD-control and call it.
http://searchpalette.com/g/g.html
This method will work with different site, I think. Also, I believe it works on a few browsers. To incorporate this int the ASP-world might not be worth it though.
If there is any interest, I could give it a try.
Gorm Braarvig

Monday, March 26, 2012

Will Atlas Work With Opera 8.60 for Pocket PC?

myAtlas Update Panels are working fine when i access the page from a standard desktop Opera browser. However the page is posting back when i do the same thing from within the PDA. the PDA is running the latest 'Opera 8.60 for Pocket PC' browser.

can i somehow configure the Atlas or the page so that it will work on the PDA browser? or am i on a hiding to nothing?

thanks

I don't speak for the ASP.Net team; however at this time there is no real 'support' for mobile devices (so yours being opera is not a slant). Currently there is some Opera desktop browser support and they are looking at expanding it. As with all new tools we get to play with - mileage will end up varying - however if you are familiar with Java Script... there may be a means for you to roll your own if its a mission critical scenario... However, personally - I don't think right now the focus is in provding mobilie support as it is more inline to polishing desktop browser experiences... NOt to sy it won't won't happen.. but usually mobile applications don't rely on the jazzability that memory / cpu intensive desktop browsers can utlize...

Will using Update Panel really give any performance improvements compared to non-AJAX site

Hi,

When one uses the Update Panel to remove the browser refresh then will there be any real performance gains as it yet does a full page postback and goes through the complete page life cycle on the server?

Using Update Panel sure makes the end user feel as though the browser refresh has been removed. But is there anything more to it?

Thanks,

- Manoj

Hi,

if you want to know more about this I would like to recommend you to check out this video that was shot on TechEd 2006 Barcelona:http://www.microsoft.com/emea/msdnshowtime/sessionh.aspx?videoid=331.

It shows the good and the bad of the UpdatePanel and how to tweak it.

Grz, Kris.


hello.

and the obvious answer is that it's not there to increase performance :)

Windows XP-Like Folder Browser

Hi I'm not sure whether I'm posting to the correct place. I am trying to create a page that allows users to create a page to my website. This page contains a "Store" button, which when clicked calls a popup window (using ModalPopupExtender), which will then prompt the user where the page is to be stored. I was thinking of making this popup look similar to a "Save File As..." dialog box in Windows. My problem is I have no idea what controls to choose or how to even start on this popup. I am fairly new to asp.net and ajax and would like to hear your feedbacks/suggestions. Thanks.Hello gulrnpink,

why not to use the standard one? Just prepare the file to store and use the
following code for this

Response.Clear
Response.AddHeader("Content-Disposition", "attachment; filename=" + targetFile.Name)

Response.AddHeader("Content-Length", targetFile.Length.ToString)
Response.ContentType = "application/"
Response.WriteFile(targetFile.FullName)

g> Hi I'm not sure whether I'm posting to the correct place. I am
g> trying to create a page that allows users to create a page to my
g> website. This page contains a "Store" button, which when clicked
g> calls a popup window (using ModalPopupExtender), which will then
g> prompt the user where the page is to be stored. I was thinking of
g> making this popup look similar to a "Save File As..." dialog box in
g> Windows. My problem is I have no idea what controls to choose or how
g> to even start on this popup. I am fairly new to asp.net and ajax and
g> would like to hear your feedbacks/suggestions. Thanks.
g>
The page will actually be stored in a table called directory, which will then be called by another page using a treeview structure. This "Folder Browser" control will be populated using the data in my directory table. The control will not be displaying the folder structure within their Windows OS. Any suggestion? Thanks.

I think you can use Membership class which is built in .NET 2.0

There you can create profile per user and about storing page you have to create folder in web root

Store the pages under that folder


Actually, before users can access my website, they are prompted to enter their logon credentials. When the logon info entered has a match in my user table, the user is then granted access to my website. Things displayed inside the website will vary depending on the user's rights.

The thing I am looking for is how I can create a folder browser much like a Windows XP's "Save File As..." dialog. In this dialog box, I am planning to have a "Path" area where in the parent folder (first level) is displayed on the top maybe using a dropdownlist by default with a box underneath containing all the subfolders at the second folder. If such subfolder contains subfolders (third level), then double-clicking on that particular folder will cause its subfolders to be displayed and replacing the "Path" area to display the parent folder of the subfolders currently being displayed. All of the said folders will be coming directly from a table in my Oracle database. I can't find any documentation to help me get started on this project. Any suggestions?


Checkout the following, it has a nice filebrowsing features based upon update panel:
http://mattberseth.com/blog/2007/07/ajax_style_folder_browser_part.html
http://mattberseth.com/blog/2007/07/hwo_to_create_an_aspnet_ajax_s.html


Thanks, Kazi. Those were some helpful sites. I can use the gridview technique to populate my child nodes. My only problem now is how I would be able to populate the dropdownlist above the gridview to show a treeview structure of my whole directory. Thanks.

I think you can modify it to suite your need.


Thats cool example