ASP.NET use AJAX to prevent a control from reloading - asp.net

I'm using VS2008 to develop my ASP.NET web site, I know how to use AJAX and update panels to perform partial page refresh, but is there any way that I can do the reverse action? i.e. can I use update panels to prevent some controls from reloads? I have a control which I don't want to be reloaded in page reloads, it is located in my master page as it should be active in all pages, what are my options now?
thanks

Try using UpdateMode property of update panel to Conditional..
When UpdateMode set to Conditional, the UpdatePanel will be updated only on postback originated by controls inside the panel or from the triggers specified.
for more info:
http://codeclimber.net.nz/archive/2007/05/24/updatemode-default-value-for-the-updatepanel-is-always.aspx
http://ajax.net-tutorials.com/controls/updatepanel-control/
Regards.

Related

How to load user controls dynamically in ASP.NET without postback

I have a ASP.Net(C#) page. When a user selects a value in dropdownlist, some new controls will be visible to him.
I am able to that now, but the page has to reload every time and state has to be maintained between postbacks.
Is there any way to do the same without reloading of the page in a easiest way possible without using ajax control toolkit?
Additional info: the data for the dropdownlist is coming from the database, and some places it has to be all server side so i can't use javascript .
You can try this idea: http://msdn.microsoft.com/en-us/library/ms178208(v=vs.100).aspx. I have not try it before but it seems logical.
you should go through updatepanel. Put all the controls inside a updatepanel which you want to show on selectedindexchanged event of the dropdownlist and write code behind on selectedindexchanged event of the dropdownlist accordingly. Hope this will help you...

Enable or Disable a Control without PostBack asp.net

Greetings, I have an ASP.Net form with some standard controls (DropDownLists and TextBoxes) that I need to be disabled or enabled based on the checked state of a checkbox control.
I currently have it working via the CheckChanged event on a postback.
Can I use Ajax to accomplish the same thing without Posting Back?
You can use Jquery or Javascript to Hide or disable the controls client side.

Can I disable an update panel programmatically?

I have a master page which has some user controls within an update panel.
I would like to put a property in this page to let the content pages to be able to enable/disable async postback way of working this page.
Can I achieve it programmatically?
Thanks
Yes you can. set EnablePartialRendering="false" on the ScriptManager, it will in effect disable the AJAX behavior of the UpdatePanel.

UserControl, PlaceHolder and UpdatePanel On PostBack

I dynamically load a User Control, with an Update Panel inside a Place Holder.
When I click a button from the User Control, should refresh the Update Panel contents, but it refresh the entire page instead, and the User Control is disappearing from the page, because the page's Page_Load does not load anything if it's a PostBack.
How I can fix it?
Whenever a partial or full postback happen , Automatically all update() method of all updatepanels fire . For preventing such this behavior you need to set UpdateMode="Conditional" property . In this situation you need to specify asynchronous trigger Or ChildrenAsTriggers=true .
for preventing a dynamically loaded-usercontrol to be disappear ,It's good to save it in ViewState , Here is a tutorial and sample application
I think you'll need to reinject the control in page_load or pre_render. Dynamically created controls don't live through postback.
Make sure you are creating the control EVERY page request, regardless of GET/POST. Also, make sure you are giving it the same ID.
I like to override the CreateChildControls method.
You need to add the control page to the page in the page_init method. It has to be added on each post back. The control will retain all the values even after adding it back.
There is a full working example at this link.

Synchronous postback with Telerik Radgrid in updatepanel

I have a RadGrid with a custom edit form (FormTemplate). The grid is in an UpdatePanel for asynchronous postbacks, as changing the selection in drop down lists and checkboxes needs to enable or disable other controls on the form. (Updating the controls synchronously is not acceptable to the user.)
As part of the edit form, I have a FileUpload control, but this does not upload the files when in an update panel.
I have tried adding the Insert/Update button as a PostBackTrigger on the UpdatePanel, but this causes an error on page load, as the UpdatePanel cannot find the control (the edit form is not open on load).
Is there a way to add/remove the trigger at runtime when the form is opened/closed?
Or is it possible to have the FileUploads work with the async-postback?
Yes, you have problem with is as FileUpload is in the list of controls that are not compatible with update panel (for more info here). One workaround for you could be swfupload. Another option is to use this jQuery plugin http://www.plupload.com/example_all_runtimes.php as stated here
There is a demo on the Telerik site that shows how to upload the files.
By using a RadAjaxPanel, RadCodeBlock and RadScriptManager with RadUploads instead of FileUploads it is possible to detect on the client side whether files have been selected for upload.
If there are files to upload, the AJAX postback can be disabled during the upload.
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultcs.aspx?product=upload&RadUrid=cde8a81e-0eb1-49ca-8c31-4dba37da90c4

Resources