Showing posts with label dialog. Show all posts
Showing posts with label dialog. Show all posts

Monday, March 26, 2012

UpdatePanel & LinkButton

Hello

I have modal dialog (window.showModalDialog) with UpdatePanel & Link button in it.

Dialog dows not allow postback.

When I use Button control i can update UpdatePanel without probkecms.

When I use LinkButton i have postback and cant get async results (new window opens with error).

Haw can i use LinkButton to update content without this problem.

Thanks

Are you using AsyncPostBackTriggers?

basic outline:

<UpdatePanel id="up1" runat="server"> <ContentTemplate> </ContentTemplate> <Triggers><!-- Place triggers here so it knows which controls trigger async postback--> <AsyncPostBackTrigger ControlID="MyControlID" /> </Triggers></UpdatePanel>

I register linkButton withRegisterAsyncPostBackControlMethod.

All works ok in common window. But in modal dialogs it invoke __doPostaBack, whitch is not allowad in dialogs.

May be It because Button have click event, but LinkButton is <a> and has href?


Could you share some code that reproduces the problem?


UpdatePanel updatePanel =newUpdatePanel();

updatePanel.UpdateMode =

UpdatePanelUpdateMode.Conditional;this.Controls.Add(updatePanel);LinkButton m_SeachLinkButton = new LinkButton ();

m_SeachLinkButton.Click += new EventHandler(FormUpdater_Event)

cell.Controls.Add(m_SeachLinkButton);

this.RegisterAsyncPostBackControl(m_SeachLinkButton.LinkButton);


This code isn't enough to reproduce the problem. It raises a lot of questions... I assume this snippet is running in a method of your page (hence "this.Controls.Add(updatePanel)". But you also do "this.RegisterAsyncPostBackControl()", yet that method is on ScriptManager. You also add the LinkButton to something called "cell", but you don't show any code for that.

I need to be able to run your code so I can see what's happening... could you please provide the entire source for a page that shows this bug?

Wednesday, March 21, 2012

Updatepanel and Literal control

I have a customer search dialog.

The user selects a row from the grid and Literal control is updated with Javascript which should close the dialog should then close and a customer account number field on the parent page should be updated.

This all works until I put the grid inside an Updatepanel - then selecting a row does cause the Literal cojntrol to be updated.

From some testing it seems that the Updatepanel is the cause of the problem - its not letting the grid update the Literal control when it is outside the Updatepanel (And when the Literal control is inside the Updatepanel - updating it doesnt do anything)

I think I can update the Literal control using something like Page.FindControl. However, I have been told that this breaks encapsulation and that I should raise an event from the grid and have the Literal control grab it.

Is raising an event the best solution ?

Updating a Literal with script used to be a great tool for me when I was doing 1.1 development, and posting back all of the time. Setting it with script won't cause the page to execute it unless the page were reloaded.

In this example, you should be fine with removing the UpdatePanel for a dialog box scenario, as a postback will simply cause the dialog window to close.


But I want the UpdatePanel on the dialog box - the user could run a number of searches for a customer before selecting one (Dont think I mentioned that) so I dont want to keep refreshing the whole thing if I can avoid it.
No, you didn't mention that. :)