Working with Dynamic Populate Extender
page 3 of 6
by Nidal Arabi
Feedback
Average Rating: 
Views (Total / Last 10 Days): 58237/ 130

Creating your Dynamic populate sample

Follow these easy steps to create your solution.

1.    Start your Visual Studio 2005 IDE.

2.    Choose Create Web Site from the menu.

3.    In this sample application we will use the Visual Basic language for the sample application.

4.    Name the solution DynamicPopulateSample.

5.    Choose ASP.NET AJAX Control Toolkit Web Site.

6.    Choose File System in the location box.

7.    Click OK to create the project.

8.    Visual Studio 2005 will create your project with a Default.aspx page and likely a readme.txt. Go ahead and get rid of the latter file.

9.    Open Default.aspx page in design view.

10. You noticed that there is a control on the page already called script manager. (Well, AJAX is really a script based implementation of the language JavaScript.) In Short, Script Manager Control manages client script for Microsoft ASP.NET AJAX pages. By default, the Script Manager control registers the script for the Microsoft AJAX Library with the page. This enables client script to use the type system extensions and to support features such as partial-page rendering and Web-service calls.

11. Inside the form tag, insert listing 1.

Listing 1: HTML Listing For Creating the checkboxes

<br />
<label for="Chk1"><input id="Chk1" type="checkbox"  name="chkpizza" 
    value="Extra Cheese" onclick="UpdatePizza(3);" />Extra Cheese</label><br />
<label for="Chk2"><input id="Chk2" type="checkbox"  name="chkpizza" value="Olive"  
    onclick="UpdatePizza(3);" />Olive</label><br />
<label for="Chk3"><input id="Chk3" type="checkbox"  name="chkpizza" 
    value="Mushrooms"  onclick="UpdatePizza(3);" />Mushrooms</label><br />
<br />

12. Also, directly after the form tag insert the JavaScript introduced in listing 2.

Listing 2: JavaScript Listing

<script type = "text/javascript"> 
  function UpdatePizza(chkcount)
  {
  var behavior = $find('dp1');
  var value = '';
  for (i = 0; i < chkcount; i++)
  {
    if (document.forms[0].chkpizza[i].checked == true)
      value = ' With ' + document.forms[0].chkpizza[i].value + ',';
  }
  if (behavior)
  {
    behavior.populate(value);
  }
}
 
Sys.Application.add_load(function()
{
  UpdatePizza(3);
}
 
);
</script>

13. Drag a panel below the checkboxes with no text in it.

14. Drag a dynamic populate extender and drop it right after the panel.

15. Formulate the dynamic populate in HTML view as described in listing 3.

Listing 3: HTML formatting of Dynamic Populate Extender

<cc1:DynamicPopulateExtender ID="DynamicPopulateExtender1" runat="server" 
    TargetControlID="Panel1" BehaviorID="dp1" ServiceMethod="GetPizza">
</cc1:DynamicPopulateExtender>

16. Last but not least, copy and insert listing 4 after the title section in the header part.

Listing 4: Web Service listing to update the panel

<script runat="server">
  <System.Web.Services.WebMethod()> _
  <System.Web.Script.Services.ScriptMethod()> _
  Public Shared Function GetPizza(ByVal contextKey As StringAs String
    Return String.Format("<span style='font-family:courier new;font-
     weight:bold;'>{0}</span>", "You Selected Pizza " + contextKey)
  End Function
</script>

17. Your code should be working, go and experiment with the solution


View Entire Article

User Comments

Title: dfghfdh   
Name: fh
Date: 12/15/2012 6:47:03 AM
Comment:
fhf
Title: yth   
Name: gh
Date: 11/26/2012 4:59:37 AM
Comment:
trh
Title: tfdhgb   
Name: gfhnbg
Date: 11/23/2012 8:36:16 AM
Comment:
gfhnjgng
Title: dynamic   
Name: rakesh
Date: 11/22/2012 3:59:44 AM
Comment:
commment
Title: filtered textbox extender   
Name: hollman
Date: 10/20/2012 8:49:12 AM
Comment:
good
Title: tgg   
Name: fh
Date: 10/15/2012 8:14:18 AM
Comment:
ch
Title: Testing web   
Name: test
Date: 9/22/2012 8:13:50 AM
Comment:
I am currently facing the need to dynamically generate a long detailed report with data retrieved from a database in an ASPNET 3.5 project in which I already use the AJAX Control Toolkit intensively. The data is provided by an ASPNET web service. The generated report is static and meant to be printed. My problem is that the data retrieval process takes about 10-15 seconds because of the database query execution time. I have the need to make the report page appear faster. I was wondering if it's possible for the report page to appear immediately with blank data and for the dynamic data to be written in the page as they arrive. In the page the data is contained in html tables with Label server controls in them and everything is inside an UpdatePanel. The report is made of different sections for each of which I have build a separate web method to provide the data. I have tried the asynchronous calls to the web service that provides the data, handling the task completion event for each of the methods, but the page doesn't load until all the data has arrived.
What solutions would you suggest?
Title: Testing   
Name: abc
Date: 9/17/2012 1:03:24 AM
Comment:
hahaha
Title: asa   
Name: dew
Date: 9/4/2012 6:21:21 AM
Comment:
xsaxaxa
Title: u   
Name: uu
Date: 8/20/2012 9:25:31 AM
Comment:
uuu
Title: asdfasf   
Name: asdfasdf
Date: 7/24/2012 4:18:31 PM
Comment:
asdfasdf
Title: cdc x   
Name: c x
Date: 5/22/2012 3:08:54 AM
Comment:
c xc
Title: dynamic populate   
Name: XYZ
Date: 6/24/2010 2:27:38 AM
Comment:
This article doesn't give proper code. For example, TargetcontrolId="Pannel1", it doesn't have this control at all, if we copy this code as it is available to our page, then how our page will create pannel control?. Don't publish irrelevant article from now onwards.... I Hope u got my point..
Title: asynchronously populate table   
Name: erion
Date: 11/5/2009 6:28:57 AM
Comment:
Hello, thank you for the article. I am currently facing the need to dynamically generate a long detailed report with data retrieved from a database in an ASPNET 3.5 project in which I already use the AJAX Control Toolkit intensively. The data is provided by an ASPNET web service. The generated report is static and meant to be printed. My problem is that the data retrieval process takes about 10-15 seconds because of the database query execution time. I have the need to make the report page appear faster. I was wondering if it's possible for the report page to appear immediately with blank data and for the dynamic data to be written in the page as they arrive. In the page the data is contained in html tables with Label server controls in them and everything is inside an UpdatePanel. The report is made of different sections for each of which I have build a separate web method to provide the data. I have tried the asynchronous calls to the web service that provides the data, handling the task completion event for each of the methods, but the page doesn't load until all the data has arrived.
What solutions would you suggest?
Title: Working with Dynamic Populate Extender   
Name: John McDonald
Date: 12/12/2008 7:22:20 PM
Comment:
Would you post a sample screen shot?






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2014 ASPAlliance.com  |  Page Processed at 10/20/2014 5:10:37 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search