Hi Here is the scenario:
I have an asp:Button on the page, and on clicking on the button, it verifies certain logic and displays a details block. This details block has bunch of web user controls, which make their own jquery ajax calls and load different controls using jquery templating plugin.
The details panel is inside a asp:Placeholder and i set visible property to true on postback.
The details panel was working fine earlier since i did not had a button click which does a postback to load the details panel. It was displayed by default earlier. How do i get my web user controls make an ajax call after the postback completes?
I got it working. I just added a hidden field on the page, and on postback i filled it with some value. On jquery instead of calling the functions directly on document ready, i checked what is the value set to the hidden field. This resolved the issue.
Related
I have created a visual webpart which means it has not form / body element in it. I have three submit buttons on the webpart. At one time, only one of there three button is visible. These button performs validation on multiple controls that are added on the webpart and then call server side methods.
Issue is that it takes time for webpart to submit and during this user can press submit button more than once which result is malfunction of the application.
I have tried jQuery solutions like adding disable attribute to submit button but it stops webpart from submitting as well.
Any help to stop multiple submit.
You can consider using Ajax for posting your form.
And, until some processing is going on server, disable UI & show a Loading Image.
Refer:
jQuery.ajax()
UpdatePanel Control Overview
UpdateProgress Control Overview
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 the following scenario. I have a page that hosts several user controls. The user controls are all surrounded by a single update panel. All user controls have a save button on them. When the save buttons are clicked the page updates the update panel as expected.
Some of the user controls contain editable list views. Whenever an action is taken on these list views, the Update Panel is NOT refreshed, but the whole page posts back. How can I get these ListViews to also refresh the Update Panel? I cannot post the code because of NDA.
There are no javascript errors on the page reported by either IE8 or Chrome.
Check the autopostback property of the dropdownlist control, if the property is set to true it tries to postback every time the selection changes.
If this does not work for you, you may wish to try implementing manual update triggers in your controls code and setting the update panel to conditional, to firmly control when you want the panel to update.
I have a web page that initially loads a drop down list. When an item is selected from the list, a web form is dynamically created during an update panel async postback.
I added watermark extenders to some of the textboxes, but the watermark does not display when the page is first updated. If I focus in and then out of one of the textboxes, the watermark then appears and seems to work fine. From examining the source, I saw that the client side creation of the watermark was being attached to the init event of Sys.Application on the client.
Here's where I'm getting confused.
1. I added a handler to the client side page Sys.Application.initialize event to see if it was called during the life cycle of an async postback. It didn't appear to fire the event.
2. I tried to raise the initialize event by adding a handler to the PageRequestManager End Request method, but the flags that check if the page was already initialized were set, so none of the individual handlers were fired.
3. After 1 & 2, I thought maybe the watermark extender was somehow being lazy loaded when I applied focus to it. So I put the $create statement that is supposed to be executed in the initialize event in the End Request event of the PageRequestManager. The client script threw an error because the watermark extender was apparantly already created.
I'm not sure what the resolution here is, outside of writing my own watermark code. Is this a limitation (will the extender only function correctly if created in the initial request for the page)? And what about the init event? I can't see it firing, but if the extender was already created, it must have???
Any help would be appreciated. Thanks.
The watermark extension gives headaches to others too. I'd suggest taking a look at a jquery watermark plugin http://jquery-watermark.googlecode.com/
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.