473,411 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

How do I load a list box on demand?

132 100+
Hi there.

Within my ASP.Net (C#) page I have a Panel which contains besides other controls, a ListBox.

This Panel is invoked by a ModalPopupExtender and when it is invoked, I'd like to populate the ListBox from an external web method. At the moment I have the Panel OnLoad calling a method which returns a DataSet that populates the ListBox, but at the moment this event runs during the Web Page Load and I was hoping this would only load when the Panel was loaded - if that makes sense..?

Hence what I am after is how to populate the ListBox within the ModalPopup's Panel control? Any help please as this one has me going in bit of a circle.

Thank you.

Mark
Mar 12 '09 #1
2 3683
Frinavale
9,735 Expert Mod 8TB
You're starting to deal with the same things that I'm dealing with these days... although my control is a bit more complicated than what you're describing... I'm actually working on something very similar.

I'll let you know how I'm currently achieving this, however I haven't worked out all the kinks in every browser yet so when you hit the same problems that I'm having maybe you can help me ;)

First of all, make sure that you have your content within an UpdatePanel...otherwise the whole page will be updated instead of just the section that you want to be updated (the section containing the ListBox that is).

Add a button to this UpdatePanel and set it's style to "display:none;"....give it an ID and text...and call it something like "UpdateListBox". In the code that handles this button, do what is necessary to update the ListBox.

Before you display your modular extender, you'll have to cause the UpdateListButton to post back to the server. To do this you'll need to add a JavaScript function to the page:

Expand|Select|Wrap|Line Numbers
  1. function UpdateListBox(){
  2.     __doPostBack('<%=UpdateListBox.ClientID %>','');
  3. }
The above code calls the ASP.NET __doPostBack function that will post back to the server. You pass it 2 parameters: the eventTarget, and eventArgument....in the above code you are passing it the ID of the UpdateListBox button as the eventTarget and nothing for the eventArgument.

(Please note that '<%= %>' is ASP short hand for the Response.Write() method..therefore this is actually executed server side. It writes the ClientID of the UpdateListBox button in its place when the HTML content is sent to the browser).

I use the __doPostBack method because it determines whether or not to do a full page postback or a partial page postback. There is another way to do this using the ASP.NET Ajax Framework/Class libraries but I'm not going to get into that because it's more restricting.


Now that you have a button within an UpdatePanel, and JavaScript that posts back to the server indicating that the UpdateListBox button is the eventTarget for the postback.....and the UpdateListBox button updates the ListBox....all you have to do is call the JavaScript function before the ModalPopupExtender displays the panel.


So, in a nutshell, that's the technique I'm using.

If you are using a pure WebMethod then you are going to have to do research on how to create a JavaScript proxy class in order to call the WebMethod.......which is more complicated and something that I haven't tried doing yet...but there's lots of information out there on the web that describes how to do this.


Cheers!

-Frinny
Mar 12 '09 #2
E11esar
132 100+
Thank you, Frinny.

I'll give that a go - hopefully this will address matters as this has been a painful one to try and catch.

M :o)
Mar 12 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Donald Tyler | last post by:
Then the only way you can do it that I can think of is to write a PHP script to do basically what PHPMyAdmin is trying to do but without the LOCAL in there. However to do that you would need to...
2
by: Hakan Ç. | last post by:
Hi, We are developing windows application with vb.net runs on oracle database.We have a server/client structure and we are using remoting technology.As you know a satisfied customer will be no...
3
by: lallous | last post by:
Hello I'm new to C# and wonder if it is possible, as it is possible in C++, to dynamically load a DLL and use it in C#. The dll is written in C++ (unmanaged) and has the following export: ...
7
by: George Copeland | last post by:
This is a request for assistance analyzing a problem we are experiencing in our VB6 development environment. All our code is developed in VB6, and our persistance layer is SQL Server. We are...
2
by: menyki | last post by:
error c: ......line 3: unable to open include file 'stdio.h error c: ....... line 4: unable to open include file 'stdlib.h' error c: ........line 5: unable to open include file 'time.h' error c:...
2
by: Ole V.-M. | last post by:
Greetings, i have a UserControl, that contains a DataList. That DataList contains as items other DataLists. example: DataList A Row 1 Nested DataList 1 Row 1
4
by: Adnan Siddiqi | last post by:
Hi I am using Walter Zorne DragnDrop lib along with graphic library for my application. the function Set_DHTML() in drag n drop library sets divs(s) for dragging purpose. the argument of...
0
by: fran_j_diaz | last post by:
Hi, I've got some web pages whiches are too heavy. My pages have TabPanels and I saw that it was possible to load a tabPanel when we click in instead of the page loading. I went to ...
1
by: Mufasa | last post by:
Does anybody have any experience with a tree view control for winforms that will automatically load on demand (I could write it myself but why bother.) Just wondering which, if any of them, are...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.