Updating an ajax model pop up in an update panel - c#

I have a page with an update panel, this page also has an ajax model popup. When I click some buttons I make some changes in code behind and then show the popup. For some reason when I click the button in the update panel no changes occur in the popup.
Debugging through the click I see that the changes are applied but the popup is not refreshed.
Any suggestions would be greatly appreciated.

You need to register a post back trigger so that the popup is completely refreshed. This is of course if you want the page to post back, otherwise if you want those changes to be reflected in the popup you will need to use javascript.
example:
asp:PostBackTrigger ControlID="UploadTemplateImageButton"

you have to set the panel visibility to false on page load.
ex: panel1.Visible=false;

Related

Bootstrap Modal Popup not working with Update Panel

I have a listview which has a child element(a button) which opens a modal popup upon click. After i add an Update Panel the pop up does not work.
The popup has some fields which when updated should refresh the listview. Tried placing it outside & inside the update panel, nothing seem to work.
Please advise. Thanks.
Try using a ModalPopupExtender and have this refer to a Panel which contains your bootstrap modal markup.
Try this for starters. ModalPopupExtender example

Modal popup extender disappears on gridview refresh

I'm having an update panel which is refreshing the gridview every 2 seconds. I've added modalpopup extender to confirm user action within the gridview. And I've wrapped all other controls in my asp page in another update panel to avoid the page being refreshed everytime.
While I think I'm only refreshing the gridview the whole page is refreshing and the modal popup extender disappear after 2 sec. Please help me with a solution.
strong text
This is how my aspx page looks like.
--Mainupdatepanel--
--div--
--table--
--dropdown--
--button--
--textbox--
--/table--
--updatePanel1
--gridview with item template buttons--
--/updatepanel1--
--updatepanel2--
--confirmbuttonextender--
--confirmbuttonextender>
--modalpopup--
--/modalpopup--
--panel--
--buttons -- for modalpopup
--/panel--
--/updatepanel2--
--/div--
--/MainUpdatepanel--
In the code behind:
Timer_click event I've called updatepanel1.update();
In the click events of the button inside gridview I've called updatepanel2.update();
If you have multiple update panels on the page and you want them to refresh independently you need to make sure you set the UpdateMode property of the update panels to Conditional
Also as it seems both update panels are in turn wrapped in a update panel you will need to alter the ChildrenAsTriggers property to be false else the mainupdatepanel will update with the inner update panels

How to highlight the linkbutton when it's clicked.

Siva here.
I have used Default aspx page with bunch of link buttons in sidebar. Using asp panel i loaded the user control in panel. Here every thing is perfect. I can't highlight the active link button without post back.
ASP has a control called the Update panel (http://msdn.microsoft.com/en-us/library/bb386454(v=vs.100).aspx)
wich basicly allows you to call events while not using the postback trigger.
i hope this helps.

Modal pop up for check box

I have a modal pop up panel and a check box in that panel. I have set check box autopostback property true. When I check mark the check box the panel disappears.
I want the panel still to be there when check box clicked because I have code for oncheckedchanged. I also have 2 buttons. If any one is clicked, the panel disappears. I tried with OnClientClick="JavaScript: return false;" for the button, but the buton_clicked event does not work for the button.
if checking/unchecking the checkbox changes the UI in the popup panel, use ajax postback to only reload the content of the panel or the updated controls instead of the whole page. Therefore your popup panel will stay there. If it simply do some processing on code behind and does not change UI, consider using webmethod and $.ajax() call.
the same concept goes to your buttons.

passing data from Ajax Modal popup extender to a textbox on the asp.net page

I have a Ajax modal popup that displays a set of options for the user. On submit button click event on the ajax modal popup, i need to pass the user selected data back to a text box on the user control (which has the modal pop up) on the calling page.
Structure/flow is as follows. There is a page and two user controls. One is a search control that has another user control that contains the user options. The master page has the search user control. When the user chooses an option in a dropdownlist in the search control, it does a mpe.Show of the user control with options. User makes his selections and hit submit button. In the button click event in the popup, i delegate an event back to the search user control which tries to set the value in one of its text boxes. Everything is going fine until this step and i can see the value but the text box never changes. It seems like the user control is already rendered and the changes are ignored. Any idea how I can get around this?
In short, how to get back the data to a control from an Ajax modal popup.
Use jquery - when the user clicks a button on the modal - use jquery to set the value field to be the data that the user has selected.
e.g.
$('#modalButton').click(function() {
var userData = $('#tbUserData').val();
$('#textBoxElsewhere').val(userData);
});
for anybody's future reference, i did a work around for this. What was happening is that, on the final button click postback, the page/parent user control load events run first and then the button click event.. so the changes that were being made in the button click event did not make it back to the parent user control on the page.. i had to add a middle step to display the user selections for approval and force the user to hit a final confirmation hit. On that post back, the changes were already available for the parent user control, and not have to wait for the button click event to trigger to grab the data. I'm sure there is a better way to do this but this is what I could come up with.

Categories