I have a page like that and the control structure is like that.
UpdatePanel
Button
ModalPopupExtender
ModalPopup Content Container
Initially, ModalPopup Content Container is an empty control.
After user clicks on the Button, a async postback will be triggered. During the postback, the server generates the content and appends to ModalPopup Content Container. Also sets the properties of ModalPopupExtender. Finally, calls ModalPopupExtender.Show() method and UpdatePanel.Update() method to show the modal popup.
This method works fine if all controls in ModalPopup Content Container contains simple control. If a control is a button that needs to postback to server side, that is a problem.
Since the controls in ModalPopup Content Container is dynamically created. If a control in ModalPopup Content Container triggers a postback event, the control must be created before RaisePostBackEvent is called in server side.
My idea is to determine whether the ModalPopupExtender is hidden or shown in client side in order to re-generate the dynamic control in ModalPopup Content Container.
So my question is how to determine a ModalPopupExtender is hidden or shown.
Of coz, if you think my method does not work at all, please give me some suggestions. Thanks!
One way is using a boolean property in ViewState to keep track of the popup condition i.e. before or after you call .Show method set it to true. Then upon closing dialog you set it to false.
You can use HiddenField as well if you want to do something on client-side.
Related
This is what I'm trying to do with AJAX:
[DropDownList]
I have a DropDownList (not inside an UpdatePanel), populated by different Products to "Add" to the database.
[UpdatePanel #1]
Below, I have an Conditional UpdatePanel that listens for "SelectedIndexChanged" on the DropDownList, when that event is triggered it adds TextBoxes to a div "productForm" inside the UpdatePanel. It creates the Form according to the Product to add.
[Button]
Below the UpdatePanel I have a button that "should" submit the form above.
[UpdatePanel #2]
I have an update panel that listens for the event on Button "Click" event. I also have a div in the ContentTemplate that should post out data that was submitted from the "Add Product Form" in the first UpdatePanel.
The thing is, when I submit (and the Controls are still visible in the first UpdatePanel. It can't read the data from the TextBoxes becaus they aren't there. Also, if I try to add all this to the same UpdatePanel, the Controls disappear whenever I click the Submit button.
Any ideas how to make something similar work?
Without the code I can suspect that when you dynamically populate first div on dropdown selected index changed event, since its within update panel, viewstate is never made aware of new controls and on submit can't post them back to server.
I've had some bad experiences with update panel and never use it other than very simple scenarios. Try getting familiar with jQuery ajax. I would do what you want to do using jQuery and web methods.
I have a radiobutton list and three placeholders in my page, out of which the radiobutton list,first and third placeholder are within updatepanel, second placeholder is not within updatepanel.
When radiobutton list selectionindex is changed, I want all three placeholders invisible. Placeholder2.visible=false code executes but still Placeholder2 is visible.
How to resolve this.
Thanks,
Viknesh.A
You should put all your placeholders in update panel on reload the page when the radio button hits (full post back) by setting AutoPostBack="true"
You should understand that by default changin radio button on a client only affects client html, so you need to pass that info to server.
Another option is to have client onclick for radiobutton and write your custom javascript function to hide your second placeholder, but don't forget to manage that situation on the server as well, when postback (either ajax or not) will occur.
Move Placeholder2 inside the UpdatePanel.
Or don't use an UpdatePanel at all.
Or use JavaScript to hide it, instead of server-side code.
I have an ascx control loaded inside a panel tied to a modal pop up panel extender.
The problem is that an action triggered by the ascx control causes a postback; when the postback completes, the panel controlled by the modal popup extender which contains the custom ascx control disappears.
It is merely hidden though with it's default
display:none
style attributes.
Does anyone know how to remedy this?
Few guesses - if you are loading the control dynamically in the panel then you should load in every post-back including partial post-back. Another issue can be check if Visible property of Panel or its parent is getting set to false accidentally when post-back occurs.
I have tow diferent implementations for the same problem.
A gridview that is binded with some data and it has a select column that has a button. When the button click is fired I know in debug that the : sender.SelectedDataKey and sender.SelectedIndex have values that I use later.
But now I whant to use the ajax accordion control. I have an Accordion, and one Pane inside. Inside that pane I have a CollapsiblePanel (that uses the CollapsiblePanelExtender). And in that CollapsiblePanel I have my Gridview.
So, only when I click on the collapsiblePanel I want to get data from DB and bind it to the GridView. But it seems that using this methot the sender.SelectedDataKey and sender.SelectedIndex are Nothing (VB) when the PageIndexChanging fires!
This does not make any sense!
The GridView is the some on both implementations and EnableViewState=true
Thank you.
With the Accordion Panel being an Ajax control, it might be adding the Update Panel in there even though you did not add one to the page. Since the GridView is inside of an Ajax control, all the events that are being triggered by the GridView are going to be captured by Ajax. You might try making the GridView button clicks an Ajax callback as well.
I have run into this problem before where the controls inside of an Ajax Update Panel or an Ajax control; such as the Accordion Panel, fire the server side event handler, but because Ajax is involved, the values were stuck back on the client side.
be sure that your controls are in the same UpdatePanel, or update the various container UpdatePanels.
I have a ListView on a page that displays a list of widgets. When a user clicks on one of the items in the list, I want to display a ModalPopup that contains controls allowing the user to operate on the item they selected.
I could easily accomplish this by placing a Panel and a ModalPopupExtender in the ListView's ItemTemplate, but this mean one set of hidden controls for each and every widget, which would massively bloat the page size. (There are going to be some rather heavyweight controls in there.) Instead I want to reuse a single ModalPopup for each of the widgets in the list.
I've done some searching but I haven't found anything that applies directly to my situation before. From what I've been able to figure out, however, I have to do something like this:
Place a Panel and a ModalPopupExtender on the page inside an UpdatePanel.
Build a custom WidgetManipulator user control that has a WidgetID property. Put this in the Panel, along with a couple OK/Cancel buttons.
In Javascript on the page, attach a click handler to each widget in the ListView that triggers a postback on the UpdatePanel.
On the UpdatePanel_Load event on the server, display the ModalPopup and then set the WidgetID propety on the WidgetManipulator to the ID of the clicked widget.
On the OKButton_Click event or CancelButton_Click event on the server, hide the ModalPopup. If OKButton was clicked, call WidgetManipulator.SaveChanges() first.
The part I haven't figured out is: How the heck do I know what widget was clicked on, and how do I pass that back to the server when I refresh the UpdatePanel? Is this even the right approach at all?
If you can use jQuery instead you could do something along the lines of these two posts:
Modal Delete Confirmation Version
Two Using jQuery SimpleModal Plugin
Demo
Inserting Content Using
jQuery SimpleModal Plugin Demo
When I need to pass data from client to server in ASP.NET AJAX, I generally use an asp:HiddenField with runat="server". Both can see it freely, but beware potential postback asynchronicity.
Sounds like you need to notify the server the widget was clicked - You may use a Timer to postback; or I'd go with option 5.