Showing posts with label multiple. Show all posts
Showing posts with label multiple. Show all posts

Monday, March 26, 2012

ListBox does not preserve selected items after using UpdatePanel

Hi there,

I have a ListBox with Multiple Selection feature. After I click the Button on the form, I should process the selected items in the ListBox. The code works fine but after I add the ListBox in an UpdatePanel, it does not preserve selected items.

Any suggestions?

Thanks,
Mosh

use hidden fields.
function addItemstoHiddenField(){
var lbPlantDest = document.getElementById("lbPlantDest");
var lbSalesDest = document.getElementById("lbSalesDest");
var lbPlantDest = document.getElementById("lbPlantSrc");
var lbSalesDest = document.getElementById("lbSalesSrc");
var hdnPlantAccess = document.getElementById('hdnPlantAccess');
var hdnSalesAccess = document.getElementById('hdnSalesAccess');
var hdnPlantAccess = document.getElementById('hdnSrcPlantAccess');
var hdnSalesAccess = document.getElementById('hdnSrcSalesAccess');
for (i = lbPlantDest.options.length - 1; i >= 0; i--) {
hdnPlantAccess.value = hdnPlantAccess.value + lbPlantDest.options[i].value + ',';
}
for (i = lbSalesDest.options.length - 1; i >= 0; i--) {
hdnSalesAccess.value = hdnSalesAccess.value + lbSalesDest.options[i].value + ',';
}
for (i = lbPlantSrc.options.length - 1; i >= 0; i--) {
hdnSrcPlantAccess.value = hdnSrcPlantAccess.value + lbPlantSrc.options[i].value + ',';
}
for (i = lbSalesSrc.options.length - 1; i >= 0; i--) {
hdnSrcSalesAccess.value = hdnSrcSalesAccess.value + lbSalesSrc.options[i].value + ',';
}
}

Saturday, March 24, 2012

Load Foreign Website into Tab

Hi,

I am using the tabpanel from the AJAX toolkit, and have created multiple tab panels...for each panel I want to load a new site into it...

For example:

Tab 1 -www.asp.net

Tab 2-www.google.com

etc etc...

Does anyone know how I can do this at all?

Thanks

Hi,

You can add iFrames to the different tabs.

More info:

http://www.w3schools.com/tags/tag_iframe.asp

http://msdn2.microsoft.com/en-us/library/ms535258.aspx

Regards


Thanks!

Wednesday, March 21, 2012

Loading Async User Controls

I have a web page with multiple user controls which causes my page to load slowly. I've been trying to upgrade the page so that the main parts of the page loads then each user control loads seperatly in an async manner similar to what the mighty pageflakes.com does. I've been search for example on how to do this for the past 3 days, and keep coming up with nothing. Can somebody please point me into a direction or give me an example on how I can load my main page, then load each control in an async manner?

Thanks,
Brandon W.

Look at the AJAX frameworkhere. It'll be a lot easier if you're using web services to feed your data directly to the user controls, but you should be able to leverage the AJAX stuff to get the behavior you want.

Loading multiple gridviews async

(probably a begginer issue) Here's my problem, I have 7 gridviews on a page... some of them are very long to load it takes about 30 seconds to load the page. I was wondering how to load them all async with the toolkit so that the users could at least see some of the gridviews before all the page gets loaded.

the Gridviews are all linked with a datasource, some SQL some objects.

Anybody have a clue?

thx.

Here is some code to setup what you need...
<%@. Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MultipleGridViewsAsync._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"/> <div><asp:UpdatePanel ID="updatePanel1" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:GridView ID="GridView1" runat="server"></asp:GridView></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="loadGrids" EventName="click" /></Triggers></asp:UpdatePanel><asp:UpdatePanel ID="updatePanel2" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:GridView ID="GridView2" runat="server"></asp:GridView></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="loadGrids" EventName="click" /></Triggers></asp:UpdatePanel><asp:UpdatePanel ID="updatePanel3" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:GridView ID="GridView3" runat="server"></asp:GridView></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="loadGrids" EventName="click" /></Triggers></asp:UpdatePanel><asp:UpdatePanel ID="updatePanel4" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:GridView ID="GridView4" runat="server"></asp:GridView></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="loadGrids" EventName="click" /></Triggers></asp:UpdatePanel> <asp:Button ID="loadGrids" runat="server" Text="Load" /> </div> </form></body></html>

Steps:

1. Put each gridview within its own update panel

2. Create a AsyncPostBackTrigger that goes off a event

3. Create that event using javascript onload to fire the updates... (sorry don't have the code for that)

4. When that even is handled on the code behind bind each datasource to the grid

This way the page loads...

Then asks for the data...

Gets the individual grids...

Renders those grids...

Sorry that I can't help you with step 3, but this should work. Look into using the javascript function :

function __doPostBack(eventTarget, eventArgument)

Hope that works for you


Sorry for the delay of my reply, I was in vacation...

Thanks for the tip but it doesn't solve my issue, what happens is all my gridview loads together after the load of my page... I wanted each gridview to show as soon as they are ready...

any other idea or am I missing somethig obvious?

loading web user controls asynchronously

I am new to asp.net ajax. I want to load multiple web user controls in a aspx page independently after the page has been loaded so that user will know that something is happening in the page rather than showing them blank screen. IS there a way to do it using Ajax or is it not possible to do so?

any help would be appreciated

You could have update panel for each user control that have a timer set as their trigger. When the timer elapses, load the user control you want into each update panel. use an update animation in each to let the user know something is happening.


This seems a bit backwards. UserControls become a part of the page itself, so delaying their "loading" isn't likely to help you. If you want to show some sort of progress or other indicator to the user while the page is processing, you can do that with an animated gif or with Remote Scripting ("AJAX").


how can i achieve remote scripting using asp.net ajax. The problem is i have couple user controls that runs heavily in database and it takes about 5 seconds to finish. I want to display the remaining content in the page while the user control is loading.

please help.


hello.

well, the only option i see is to laod the page without that content and then call a web service from the client side that gets the data from the server and presents them to the user. you should keep in mind that an asp.net page generates html that is sent back to the client. this means that you cannot sent the page to the client with "wholes" that will be filled up later...it simply doesn't work like that!


It's true you can't leave holes in the HTML, but that doesn't mean you need load everything at one time.

If you modify your user control to not load the data that takes five minutes on page load, but only to load it when a certain method is run you can load the user controls in the update panels as I suggest above and then you can trigger the data to be loaded into it via a timer, or a java script function that runs when the page loads in the client's browser.


hello again.

true, but in those cases, why not simply call a web service and then use js to update the ui without incurring in another partial postback?


If you do that can you use the updatePanel animation to notify the user that something is happening or do you have do it manually with js?


hello.

well, the updateprogress is really a wrapper around client behavior that is responsible for showing/hiding the contents you define. the upadteprogress is "tied up" with the partial postback model based on the server side approach.

nothing prevents you from doing something like this is js:

1. define the wait msg in an html element that has its display style set to no none

2. start the web service call and change the display of the element defined on 1

~3. handle the cb and error cb methods and make sure that you set the style of the element defined on 1 to none

yes, you do have to write some js code, but when you think about it, the J in AJAX stands for Javascript, right? :)


i am thinking to call the update panel after onload event using javascript. is there any idea how to call update panel using javascript.


hello.

well, the easiest way i've seen is to call __doPostBack and pass it the client id of the panel you want to update:

http://encosia.com/2007/07/13/easily-refresh-an-updatepanel-using-javascript/


I just came accross a post where xr280xr says he acomplished exactly what you're trying to do using a timer.http://forums.asp.net/t/1176152.aspx


well, i'm sure that the timer has its uses, but if you just want to refresh the panel after the page has been loaded through js code, the link i've mentioned is the best option.


I'm happy to defer to your increased experience and knowledge on this, but can you explain why it would be preferable to go through the hassle of manually writing a JS function to do it as opposed to just using the timer as described in that post. I truly don't mean this in a rude way; I just don't see the benefit. Could you explain?


Luis,the link you provided is not working. would you please provide again.