Showing posts with label implemented. Show all posts
Showing posts with label implemented. Show all posts

Monday, March 26, 2012

UpdatePanel - works on one page, but not on another

I've implemented the MS Ajax UpdatePanel on one page in a site to to load a combo based on the selection of another combo without a postback.

It worked perfectly on my development machine, but failed without any javascript error or exception on the server. I suspected the config was a problem and made sure that all the options in my development config were transferred to the server--specifically, the Assembly binding and HTTPHandler settings. I downloaded and installed the Ajax Extensions MSI package on the web server, which is 2003.

A test page with just an update panel, a button, and a label works without postbacks when uploaded to the same web application, so it looks to me like the config is set up properly. The page that it doesn't work on inherits from a master page, and has the update panel in a usercontrol... When I save the page in IE, I can see that the Ajax scripts are being loaded in the scriptmanager resources.

What steps would I take next to figure out the problem?

It sounds very strange that asp:Update can work in one?web page,but not in another web page.Try to test your Ajax website in development machine through IIS and check if it works.There is no doubt that Ajax can work with master page/content page.Try to check the permissions in IIS which may affect the execution results.Do you create a web?application?when?you?create?a?new?
virtual?directory??Do?you?set?Executable?Permissions?for?"Scripts only"?or?"Scripts and Executable"??Try?to?add?"Network Service"?to?the?virtual?directory?in?IIS?through?right?mouse?clicking?on?the?virtual?directory.
If you still have any questions about this,try to post some codes here which will help us to fix the problem.
Wish this can help you.

Saturday, March 24, 2012

UpdatePanel and __doPostBack

My app loads one of several dynamically generated reports, implemented as user Controls, (*.ascx files) into an Update Panel. I am trying to do this without a page postback. However, client side code needs to validate several things before issuing the asynchronous request. In IE, I was using an ASP.Net custom Validator control hooked to a client side script
(GenerateReport(sender, e) {...}
to control this, (usinge.valid = true/false; to control whether the asynchronous request to update the content in the UpdatePanel was sent or not, but I have discovered that Firefox does not implement ASP.Net Validators properly.

So now I am trying to accomplish the same functionality simply using a client side script that calls __doPostBack(eventTarget, eventArgs);
But I can't seem to get the __doPostBack to call the Microsoft AJAX asynhcronous call, instead of doing a complete page postback.

How do I do that? Or is there a better way to do this.

Another option I have considered is to put the user control into a web service, that somehow just returns the innerHTML of the user5 control rendering process, but I can;t seem to figure that out either..

ideas anyone?

I've been fighting the same problem the last couple of days. Here is what I just finally came up with...

I write the __doPostBack on the server side and insert it into an onClick event on a control.

String sOnClick

="__doPostBack('" +this.UpdatePanel1.UniqueID +"','eventarg1$eventarg2');"; // the Update Panel's UniqueID will call the asynchronous request and pass the event argument string

e.Row.Attributes.Add("onClick",sOnClick); // I'm adding this to a gridview, I'm guessing this will work elsewhere too.

Then in the Page_Load I parse the event arguments and call the appropriate function

StringsEventArguments =this.Request.Params["__EVENTARGUMENT"];if(sEventArguments !=null)

{

Int32iDelimiter =sEventArguments.IndexOf('$');

StringsArgument =sEventArguments.Substring(iDelimiter + 1);

if (sEventArguments.StartsWith("eventarg1")) EventFunction(sArgument);

}

I hope this helps.

G


You canuse __doPostBack() to refresh an UpdatePanel, if you target the UpdatePanel itself.