Showing posts with label based. Show all posts
Showing posts with label based. 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.

UpdatePanel : Add TRIGGERS programatically for dynamically generated controls

I thought this would be an easy task but evidently not. Here is the situation: I have anupdatePanel that needs to be refreshed based ontriggers that are suppose to bedynamically generated controls. How do I go about doing this? I can not add Triggers to updatePanel for the controls that are not yet created.

STEPS:

    Initialized 10 controls dynamically : Lets say Button controlsupdatePanel initializedtriggers added to updatePanel for the newly generated controlsbadabing - they all TRIGGER the updatePanel behavior...

My sequence may even be wrong. Maybe the updatePanel has to be created programatically too, I don't know. First of all how to do it that it works and then whats considered the best practise? Anyone?

Cheers...

Ok, I figured it out after thinking and searching for a bit. Here is the solution:

--------

publicvoid createDynamicUpdatePanel()
{

Button btnAsTrigger;
AsyncPostBackTrigger trigForBtns;

// Create Multiple Controls
int ctrlCount = 0;
for (int i = 0; i < 5; i++)

{

btnAsTrigger =

newButton();
btnAsTrigger.ID ="btnAsTrigger" + i.ToString();
btnAsTrigger.Text ="btnAsTrigger " + i.ToString();

trigForBtns =

newAsyncPostBackTrigger();
trigForBtns.ControlID = btnAsTrigger.ID;
trigForBtns.EventName ="Click";// Add controls to the form
Form.Controls.Add(btnAsTrigger);
ctrlCount = i + 1;

}

// Create label Control : For updatePanel Content
Label myLabel =newLabel();
myLabel.Text =DateTime.Now.ToString();// Create UpdatePanel
UpdatePanel myUpdatePanel =newUpdatePanel();
myUpdatePanel.ID ="updatePanelDynamic";
myUpdatePanel.UpdateMode =UpdatePanelUpdateMode.Conditional;
myUpdatePanel.ContentTemplateContainer.Controls.Add(myLabel);// Create Triggers for all previosuly generated controls
for (int i = 0; i < ctrlCount; i++)
{
AsyncPostBackTrigger trigAsynPostback =newAsyncPostBackTrigger();
trigAsynPostback.ControlID ="btnAsTrigger" + i.ToString();
trigAsynPostback.EventName ="Click";
myUpdatePanel.Triggers.Add(trigAsynPostback);

}

// Make it happen
Form.Controls.Add(myUpdatePanel);

}

Works like a charm... Thats all there was to it. Anyway if someone has a more elegant way to do this, please do post your solution.
Thanks


Screwed up the formatting up there, here we go again:

public void createDynamicUpdatePanel()
{
Button btnAsTrigger;
AsyncPostBackTrigger trigForBtns;

// Create Multiple Controls
int ctrlCount = 0;
for (int i = 0; i < 5; i++)
{
btnAsTrigger =new Button();
btnAsTrigger.ID ="btnAsTrigger" + i.ToString();
btnAsTrigger.Text ="btnAsTrigger " + i.ToString();

trigForBtns =new AsyncPostBackTrigger();
trigForBtns.ControlID = btnAsTrigger.ID;
trigForBtns.EventName ="Click";

// Add controls to the form
Form.Controls.Add(btnAsTrigger);

ctrlCount = i + 1;
}

// Create label Control : For updatePanel Content
Label myLabel =new Label();
myLabel.Text = DateTime.Now.ToString();

// Create UpdatePanel
UpdatePanel myUpdatePanel =new UpdatePanel();
myUpdatePanel.ID ="updatePanelDynamic";
myUpdatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
myUpdatePanel.ContentTemplateContainer.Controls.Add(myLabel);

// Create Triggers for all previosuly generated controls
for (int i = 0; i < ctrlCount; i++)
{
AsyncPostBackTrigger trigAsynPostback =new AsyncPostBackTrigger();
trigAsynPostback.ControlID ="btnAsTrigger" + i.ToString();
trigAsynPostback.EventName ="Click";

myUpdatePanel.Triggers.Add(trigAsynPostback);
}

// Make it happen
Form.Controls.Add(myUpdatePanel);
}

Wednesday, March 21, 2012

UpdatePanel and Server.transfer

I have a gridview inside a updatepanel that, based on the click of a button (commandbutton) postback to server and process the some code (associated with the command event) the page fails to do a Server.transfer("xx.aspx") The code is executed but the page "postback" to the old page not the
"transfer to page". Can't you do an Server.Transfer from a control inside a AtlasPanel ??


hello.

well, i think you won't be able to do that. if you use fiddler, you'll notice that you're getting a pageError element (which doesn't really gives any util info).

though i'm not sure about it, i'd say that you're getting an error from the application itself since the pageerror event of the control isn't being fired.

I'm a little bit puzzled as well. It seems that through this update panel, which is doing a partial rendering of a page, you can't end execution of the main page because of the page's lifecycle. Honestly, that is just a guess. I would be curious to hear from Mike or someone on this.

\=)


Server.Transfer does not make sense when you use updatepanels - the client is expecting fragments of rendering to update an update panel, and not an entire new html document. For buttons that result in Server.Transfer, make sure they aren't set up as triggers for update panels.
i also had encoutner this problem.
does anyone have any solution for this problem?

Hi,

As Nikhil pointed out, doing a Server.Transfer doesn't really make sense in an AJAX callback situation.

Also, it seems according to microsoft unless you're writing an ApplicationController Server.Transfer is probably not a good concept to use at all as it doesn't sit very well with search engines. I guess the only other time one would perhaps use it is if you want to display completely different pages based on certain criteria (like depending on if the user has logged in), but I would think this determination is probably best done in a HttpHandler. I myself usually dynamically load user controls for that though.

Nick


You may as well try Response.Redirect.

Hi,

Response.Redirect have the same (logical) problem.


Hi!

I know that this thread is a bit old, but I had a similar problem with Server.Transfer and UpdatePanels.

I found a working solution athttp://brunokenj.net/blog/index.php/2007/04/09/utilizando-servertransfer-e-aspnet-ajax-10/

Look at the first comment of the blog entry to get the code I am using.

It would be nice If I got some opinions about this solution.