Showing posts with label tree. Show all posts
Showing posts with label tree. Show all posts

Wednesday, March 28, 2012

Tree control

Hi,

I would like a scalable, extendable, customizable, localizable fully asynchronous tree control. Is such a beast available?

Many thanks!

TimHi Tim,

There isn't anything that does everything you want out of the box. Your best bet is to look at using the ASP.NETTreeView inside an "Atlas"UpdatePanel. The current issue of MSDN magazine actually has anarticle by Jeff Prosise exploring some practical ways of doing this.

Thanks,
Ted

Thanks Ted. It seems like a good candidate for addition to the toolkit. Ideally I would like to create a completely control driven application and implemented very cleanly. Best regards, Tim

Tree Control within Grid Control using AJAX and ASP.Net

Hi, I need a tree control inside a grid control, i.e.., every node of the tree should be a row in the grid control. I want to implemented this using AJAX. Please let me know how this has to be implemented.

Hi

every node of the tree should be a row in the grid control?

I'm afraid you cann't implement this,Html can be writed like this.

Best Regards

Tree Control within Grid Control using AJAX

Hi,
I need a tree control inside a grid control, i.e.., every node of the tree should be a row in the grid control.
I want to implemented this using AJAX. Please let me know how this has to be implemented.

Hi TinyTin,

I have found that you have posted the same thread on Asp.Net Ajax UI with this url: http://forums.asp.net/t/1141859.aspx. so we will mark it as "resolved", if you have any problems or new findings , please feel free to reply onhttp://forums.asp.net/t/1141859.aspx.

By the way, based on my experience, I'm afraid that we cannot achieve what you want by using any controls in Ajax Control Toolkit directly. Thanks.

Best Regards,

Jonathan

tree view + no postback + update panel

setup:

master page - content page layout

On my content page I want two update panels, one to contain a tree view dynamically generated from a database and the other to contain dynamically generated data (also pulled from a database) based on what is selected in the tree view. It is my understanding that tree view cannot be in an update panel. What is the best strategy for accomplishing this? I don't want a postback to be performed when an item is selected in the tree view. In other words, I don't want the entire page (form) refreshed just because an item in the tree view is selected.

Thanks in advance for any help.

If your treeview doesn't change the contents after the PageLoad, you may be able to have it in an update panel. We found that it doesn't work well if you add nodes to the treeview when you click a parent node, but if you load the full treeview it may be ok. If you need to dynamically add nodes as you click, you would probably need something like the TreeView that telerik has. We were looking at that one until we decided to do our page differently, and that control is not free, but seems to work nice.

The 2nd update panel would have a grid view in it. From the grid view I would add or edit content. If I added content the tree view would need to be refreshed without a full page postback to display the newly added item.

From the sounds of it, this isn't possible with strictly MS controls at the moment.


I just finished this very thing. The page starts with just a pulldown and then based on that value creates a Treeview dynamically without refreshing the page. Then clicking on a node causes another update panel to refresh with specific information.

Pretty convoluted with half Telerik and half MS. The full Telerik approach (Treeview and Update panel) looks easier, but we are using MS AJAX.

My older version of the Treeview (5.3) does not work with MS update panel, so I need to upgrade. I'm not too happy about it, but it seems to work well.

WISH LIST: A direct JavaScript method to postback to an MS update panel. As it is this seems to be the best approach:

http://forums.asp.net/thread/1541012.aspx


I followed the instructions on that thread and I have my update panel refreshing from javascript code. How do I call a javascript function when a tree node is clicked?

in the Telerik Treeview there is a property called "onBeforeNodeClick" and you can set that to the name of a javaScript function to fire when a node is clicked and before postback.


So, I did

myTreeNode.NavigateUrl ="javascript:postBackHiddenField('hardcodedhiddenfieldcontrol','" + uniqueIdentifierOfTreeNode +"')"function postBackHiddenField(hiddenFieldID, clickedID){alert("works");var hiddenField = $get(hiddenFieldID);__doPostBack(hiddenFieldID,'');}
 
I want to use the uniqueIdentifierOfTreeNode in order to modify the select paramter of a gridview in the update panel I'm refreshing from __doPostBack. I have no idea. Any help is appreciated. Is this the best approach to take even?

I forgot to mention the postback and refresh of the update panel is working as I have a label refreshed with the system time.
Nevermind, it looks like I came up with a reasonable solution that works.

Tree view control with ajax

Hello,

I dont know, is this the right thread to post my prob. Here is my problem. I have a tree view control in a master page. I have created that tree view from "treeview.xml" file. I have created this file from database table. In this tree view, more than one node may have same name. My table has four fields - nodeid, nodename, parentid and lavel. The xml file looks like...

<?xml version='1.0' encoding='utf-8' ?>
<rootNode>
<siteNode title="root" id="1">
<siteNode title="my document" id="3">
<siteNode title="my films" id="31">
<siteNode title="bengalis" id="33">
<siteNode title="aaa102" id="102" />
<siteNode title="aaa106" id="106">
<siteNode title="xxxx1" id="1051" />
<siteNode title="xxxx1" id="1053" />
<siteNode title="zzzz2" id="1059" />
...
...
Every node may have more than one information. All these informations are stored in a different file with "nodeid". What I want is that when any one click on any node I want to display all the information stored in that node in the "Conten Page" with the help of Ajax. For that I need the id of that selected node. How can I access the node id?

Angshujit

Do you want the tree view to dynamically add nodes when you click one of the nodes? If so, you will have a lot of problems using the built in controls for that because the treeview is not supported inside an update panel. You can generally have a treeview in an update panel if it doesn't change the contents, but if you want it to change after page load, you should look at getting a 3rd part control for it.

Hello,

Thank you for your reply. No, I dont want so at present. Actually what is became my headache is how to get the id of the node.

protectedvoid SelectedNodeChanged(object sender,EventArgs e)

{

string id = treeView1.SelectedNode.?

Because without knowing the id I cannot search the table for contents belongs to that node. I cannot usetreeView1.SelectedNode.Text becasue there may be more than one nodes with same text. Is there any way to solve it? Please help me.

Angshujit

Tree view nested in Accordion taking two clicks to fire selectedNodeChanged event

I have a treeview in one of my accordion panes. When I click on a node for the first time, instead of firing the selectedNodeChanged event, it just goes through a normal postback. However the second time I click it, the event is fired correctly. Is there another event being fired that I'm not seeing?

Here's a trimed down version of the code. Thanks for any ideas. -d

<atlasToolKit:Accordion ID="navAccordion" runat="server" Height="410"
FadeTransitions="true" FramesPerSecond="40"
TransitionDuration="250"
AutoSize="None"
>

<atlasToolKit:AccordionPane ID="AccordionPane2" runat="server">
<Header><a href="http://links.10026.com/?link=" onclick="return false;" class="accordionLink">Tank Groups</a></Header>
<Content>
<asp:Panel ID="navPanel" runat="server" ScrollBars="auto" CssClass="extraPadding" BackColor="white" Width="180" Height="200">
<asp:TreeView ID="navTankGroups" OnUnload="nav_Unload" OnSelectedNodeChanged="nav_SelectedNodeChanged" runat="server" SkinID="nav" >
<Nodes>
<asp:TreeNode Text="Page 1" Value="~/page1.aspx" />
<asp:TreeNode Text="Page 2" Value="~/page2.aspx" />
</Nodes>
</asp:TreeView>
</asp:Panel>
</Content>
</atlasToolKit:AccordionPane>
</atlasToolKit:Accordion>

Here's the selectedNodeChanged routine.

Protected Sub nav_selecedNodeChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim navTankGroups As TreeView = CType(AccordionPane2.ContentContainer.FindControl("navTankGroups"), TreeView)
If Not navSchedule.SelectedNode.ValuePath = String.Empty Then
Response.Redirect(navTankGroups.SelectedNode.Value)
End If
End Sub


This appears to only be an issue on master pages. I placed the accordion in a new page and it worked fine. Anyone have an idea on why it is taking two clicks in the masterpages? -d

Hi dtamber,

I'm not sure what's going on with this... could you perhaps post the simplest possible version you have that still causes the problem?

Thanks,
Ted


Look at the source code before and after the button click, there is one of 2 possibilities.

1. someting being created dynamicly doesn't have an ID property set, in this case you'll see the treeview control in the source with different names

Like ctl03 and ctl05 in the treeview's name

2. I have fixed my postback issues by adding a hidden field to each accordion pane at page_init. I don't know why this fixes the erradic behavior, but it does.

Let me know if either of these works.

Chris


I think this needs a bump.

I just tried using an accordion in a usercontrol and added 3 panes, each containing an updatepanel containing a button.

The button click event is not fired. Adding a hidden field as Chris suggested allows the click event to fire.

Nathan


I also ran into the exact same problem. I was using a gridview inside an accordion and the events weren't firing the first attempt. If you add a control to it during OnInit then it appears to work. My assumption is that there's a problem with the RenderControls or something.

Astynax777:

I also ran into the exact same problem. I was using a gridview inside an accordion and the events weren't firing the first attempt. If you add a control to it during OnInit then it appears to work. My assumption is that there's a problem with the RenderControls or something.

Astynaxx777 - This clicking twice problem has been a real issue for me. Can you please elaborate with a small example if possible? You mean to add a control to the AccordionPane when the page loads (through the code behind)?

Your help would be greatly appreciated.


I ran into the same problem where I couldn't get a Button click event to fire off until I did whatCConchelos tried:

"2. I have fixed my postback issues by adding a hidden field to each accordion pane at page_init. I don't know why this fixes the erradic behavior, but it does."

Here's a basic example:

 
<body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> </div> <cc1:Accordion ID="Accordion1" runat="server"> <Panes> <cc1:AccordionPane ID="AccordionPane1" runat="server"> <Header>Test1</Header> <Content> <asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton> </Content> </cc1:AccordionPane> <cc1:AccordionPane ID="AccordionPane2" runat="server"> <Header>Test2</Header> <Content> <asp:Button ID="Button1" runat="server" Text="Button" /> </Content> </cc1:AccordionPane> </Panes> </cc1:Accordion> </form></body>

The Button1 click event would not get called until I added a hidden field to the AccordionPane that contained Button1 on the Page_Init:

Private Sub Page_Init(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles MyBase.InitDim myAccordionPaneAs AccordionPaneDim myTextBoxAs New TextBox myTextBox.Visible =False myAccordionPane =MyBase.FindControl("AccordionPane2") myAccordionPane.Controls.Add(myTextBox)End Sub

I thinkAstynax777 is right - there must be something wrong with the controls inside an AccordionPane when being rendered.


Thank you very much. It should be noted that after Astynax777's suggestion I tried it with a button and I forgot to hide it, and it didn't work as expected.

Excellent example, thanks again.


Hi,

has anyone found out more about this issue? As indicated in a previous post, the issue appears to be that controls are not rendered properly the first time the accordion is loaded. When the postback occurs, the controls have a different id, and no event is fired since it cannot be hooked up to the appropriate control (since the ID has changed).

I have a slightly different problem than those posted above as the accordion I'm working with is loaded via a datasource. I cannot add controls on the init event as a temporary fix. Any idea for a workaround would be greatly appreciated until this is resolved.

Thanks


btw, this "click twice" error disappears when I have only 1 accordion control on a page. If there are two accordion controls (one is data bound, the other is not), then I have to click twice. When I only have the databound accordion, it works as intended.

The good thing is that adding the "invisible" control to each pane in the Accordion which is not databound has fixed the "click twice" error in the databound Accordion.


Ok, I think I have this problem fixed. You can see the changes I made athttp://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=5796 . There's 2 files I uploaded for that issue. I might help you... or it might not, I have not tested it for your problem but it certainly fixed mine! Good luck.


Has anybody else tried it with the new 10660 release? For me, the event handling never worked. My accordion is completely databound and does not contain any unbound panes. Consequently, the workaround will not work for me. I've just tried it with 10660, but no change.

Dennis Doomen
Aviva Solutions


I was having all of those 'click twice' problems but in randomly places. I used Accordions on many different pages and I couldnt figure out why it worked on some pages and didnt on others. I realized that on the page that it didnt work I was doing my control loading during OnInit and on my other pages that did work it was during PageLoad. Im guessing you have to make sure that everything must be done in one or the other. If you have User Controls make sure that your logic and things are also in it's page load as well. Dont mix and match :)

Tree, Menu, etc not usable in UpdatePanel. Any workarounds?

I spent a long (probably too long before checking the forums) time tracking down the "0.cells is null or not an object" problem. To come to find out that the tree, the menu, and the grid don't work with the UpdatePanel (See notes near bottom ofhere).

I'm wondering if there are any workarounds that anyone has come up with. This kinda sucks since part of my design was to use a goodly amount of popups that allow modifications and those are nicely handled using menus, trees, and such. I know that microsoft says they're working on some ajax based controls that wrap these other controls up. But the need is kinda here and now (Maybe I just don't have a latest update of ACT or something?) Anyway using Telerik or some other commercial control is just not feasible in my budget at the moment. So I thought I'd see if anyone had any workarounds.

For that matter does anyone have any workarounds for accordions to make them horizontal (to make them open and close left to right instead of up and down)?

I'm thinking that some other people have experienced some problems such as these and might be working on some ideas as far as workarounds.If so then perhaps we could "band together" and create an area on CodePlex (and possibly some referers at google, sourceforge and the like) to at least give some pointers to some other efforts to expand on the ACT.

Anyway just wanted to throw that alternate idea out there, but if anyone has any viable workarounds for the lack of support of trees, grids, and menus in the UpdatePanel, I and probably many others would be glad to hear about it.

Thanks in advance,
Christopher

The UpdatePanel included in the .Net framework 3.5 supports having treeview and menu controls in them. There is a go live license for VS 2008. Maybe you can use VS 2008

http://blogs.msdn.com/somasegar/archive/2007/09/08/asp-net-enhancements-in-vs2008-and-net-fx3-5.aspx


I am not sure that the TreeView is supported in .NET 3.5. My suggestion is to use any third pary javascript library for the treeview and use WebService for the data transfer.


yeah moving up to VS2k8 and moving up to .NET 3.X (3.5 in beta) doesn't seem like an option (at this point) to have this "design paradigm" adopted. It means to many other adoption points. Hmm I'll keep you all updated I guess as far as any solutions, but if anyone else has something to contribute I'm quite willing to work with them. In my mind this begs further investigation. ;-)


Controls that Are Not Compatible with UpdatePanel Controls

The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside anUpdatePanel control:

TreeView andMenu controls.

Web Parts controls. For more information, seeASP.NET Web Parts Controls.

FileUpload controls when they are used to upload files as part of an asynchronous postback.

GridView andDetailsView controls when their EnableSortingAndPagingCallbacks property is set totrue. The default isfalse.

Login,PasswordRecovery,ChangePassword, andCreateUserWizard controls whose contents have not been converted to editable templates.

TheSubstitution control.

Validation controls, which includes theBaseCompareValidator,BaseValidator,CompareValidator,CustomValidator,RangeValidator,RegularExpressionValidator,RequiredFieldValidator, andValidationSummary control.


Yes that's what I was saying in my original post when I said that they don't work with an update panel and referred to the document thru a link. So I guess I'm missing your point in posting that with no statements by you. Is there some workaround that I'm missing in my reading of it?

Thanks in advance,
Christopher

Monday, March 26, 2012

Treeview is slow to respond when a node is selected

I am working on an application that is using the TreeView.

Theway it's functions is the tree displays all the available families offunds. When the node is expanded, it shows the funds for thatparticular family (PopulateOnDemand is set to true). When the fund isclicked, it's added to a checkbox list. It's working, but when the fundis getting added to the checkbox list it's very, very slow. I'd like to get rid of the lag, because it's pretty unusable at this state

I am posing my code, and i hope someone can help me

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Copy of Default.aspx.cs"
Inherits="_Default" %
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<link href="Local_Resources/StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<table>
<tr>
<td valign="top">
<cc1:TabContainer ID="TabContainer1" runat="server" Width="460px" Height="400px" ScrollBars="Auto">
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Browse Funds">
<ContentTemplate>
<asp:UpdatePanel runat="server" UpdateMode="conditional" ID="tvUpdatePanel">
<ContentTemplate>
<asp:TreeView ID="TreeView1" OnTreeNodePopulate="PopulateNode" OnSelectedNodeChanged="SelectNode" ExpandDepth="0" runat="server">
<Nodes>
<asp:TreeNode Text="root" SelectAction="Expand" PopulateOnDemand="true" />
</Nodes>
</asp:TreeView>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</td>
<td valign="top">
<asp:UpdatePanel runat="server" ID="upResult" UpdateMode="Always">
<ContentTemplate>
<div class="checkboxListWrapper">
<asp:CheckBoxList ID="cblResults" runat="server" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partialclass _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

}
}

protected void PopulateNode(object source, TreeNodeEventArgs e)
{
switch (e.Node.Depth)
{
case 0:
GetFundFamilies(e.Node);
break;
case 1:
GetFundsByFamily(e.Node);
break;
}
}
protected void GetFundFamilies(TreeNode node)
{
foreach (DataRow drin DAL.getAllFundFamilies().Tables[0].Rows)
{
TreeNode tempNode =new TreeNode(dr[1].ToString(), dr[0].ToString());
tempNode.SelectAction = TreeNodeSelectAction.Expand;
tempNode.PopulateOnDemand =true;
node.ChildNodes.Add(tempNode);
}
}
protected void GetFundsByFamily(TreeNode node)
{
foreach (DataRow drin DAL.getFundsByFamily(node.Value.ToString()).Tables[0].Rows)
{
TreeNode tempNode =new TreeNode(dr[1].ToString(), dr[0].ToString());
node.ChildNodes.Add(tempNode);
}
}
protected void SelectNode(object sender, EventArgs e)
{
TreeView tv = (TreeView)sender;
ListItem li =new ListItem(tv.SelectedNode.Text, tv.SelectedNode.Value);
cblResults.Items.Add(li);

}

}

TreeViews are supported in update panels. You can kind of use them, BUT you will get errors if you try to change a treeview after the initial pageload. If it doesn't change, you should be able to use a treeview inside an update panel without errors. Menus and report viewers are also not supported.

Well, that doesn't answer my question. My tree works just fine. It's just very slow.

When doing some testing i found that when i click on a node, it looks like the entire tree reloads. I don't think i have that problem when i am not using the UpdatePanel, but that defeats the purpose.


Well, that doesn't answer my question. My tree works just fine. It's just very slow.

When doing some testing i found that when i click on a node, it looks like the entire tree reloads. I don't think i have that problem when i am not using the UpdatePanel, but that defeats the purpose.


My point was that you CAN'T get Ajax functionality with the built in Treeview. If you want that, you need a 3rd party control.

in that case i am confused

if it would work, it would just not work. My problem is that it IS working. I just need it to be faster.

I am guessing you mean it doesn't support asynchronous postback? But i can the child nodes to populate on demand without a page reload. If i can't get the tree to work, i can just adapt a GridView for my purposes, or just write a custom control. I don't need too much functionality.


You would probably want to adapt the gridview then. Since the Beta releases, treeviews haven't worked well, if at all when you try to do anything dynamic with them after the initial page load. Before the betas, there was a way to do this, but there were big changes that changed that. We spent a lot of time trying to get it to load dynamically when we were switching our site from the July CTP to releases after that.

that's what i am trying to do right now actually

even with a gridview it's tricky and i ran into the same problem of the whole grid expanding when a node is clicked

i guess i need to add multiple update panels to make it work

Trigger a panel refresh from javascript/pure html control

Hi,

I have a pure HTML tree control, that is outside of an ajax UpdatePanel. I want to write a JS function that triggers a particular panel to refresh, *as if* I hit a submit button inside of the panel. I don't want to put the HTML tree control inside an Ajax panel, as it will loose it's state (it will return to a completely collapsed state).

Putting a button inside the panel, and then running the JSelement.click() event from my tree control works in IE, but Firefox submits the entire page(the submit event is not captured by the AJAX framework in FF in this case,apparently).

I have looked into the client reference documentation at http://ajax.asp.net/docs/ClientReference/Global/default.aspx, and it seems like there should be a way to trigger a postback/panel refresh, but I have not found a way.

The PageRequestManager does not help, since it only monitors existing page requests. I need to invoke a page request, and run something like

PageRequest.Invoke('MyUpdatePanel');

or

var ajaxpanel = document.getElementById('AjaxPanelClientID');
ajaxpanel.update();

A related suggestion:

It would be nice if the UpdatePanel supported client side triggers, not just server side triggers. Consider the following hypothetical code:

<ajax:UpdatePanel ID="ajxUpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<!-- CONTENT -->
</ContentTemplate>
<Triggers >
<ajax:AsyncPostBackTrigger ClientTriggerFunction="MyCustomTrigger" OnTrigger="MyCustomTrigger_ontrigger" />
</Triggers>
</ajax:UpdatePanel>

Then the system would automatically generate the JS function (with the appropriate .NET ajax framework calls that I don't need to know about), so I can call it anywhere on the page, from multiple HTML controls if needed.

<input type="button" value="MyHTMLButton" onclick="MyCustomTrigger('argstring');">

The system should enable a code-behind event handler where I can put my server side code:

protected void MyCustomTrigger_ontrigger(object sender, AjaxClientTriggerEventArgs e) {
//run some server side .NET code here
switch(e.ClientArgString){
...
}
}


You can trigger an asynchronous post back by invoking the __doPostBack function. Just pass in the ID of the control that's either inside an update panel or is marked as a trigger for one. Here's an example:

<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<asp:Button ID="myButton" runat="server" OnClick="myButton_Click" Text="Click me!" />
<asp:Label ID="myLabel" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<input id="myOtherButton" type="button" value="No, click me!" />
<script type="text/javascript">
function pageLoad() {
$addHandler($get('myOtherButton'), 'click', triggerAsyncPostBack);
}
function triggerAsyncPostBack(e) {
__doPostBack('<%= myButton.UniqueID%>', '');
}
</script>

One thing to watch out for is that the first parameter to __doPostBack needs to be the full ID of the control. If you're using master pages, your control IDs will be longer than they appear. Use the UniqueID property to get the full ID or the event handlers for your control won't run on the server.

Also, if you have event validation turned on (the default), you'll get an exception if you don't pass in a correct event argument as the second parameter to __doPostBack. For button controls, it should be the empty string. For other controls, it might be different, but you'll have to experiment to find out.

Hope this helps.


Thank you Jason,

That is the behaviour I was looking for, and it works in Firefox as well as IE. I knew about the _doPostBack function in general, but I did not know the syntax to call it.

Where is the best place to find documentation and syntax for the built-in ASP.NET and AJAX JS functions and calls? For example, I did not know about $get or $addHandler functions.

(I am familiar with similar functions from the prototype.js library).

Thanks again :-)


Another related discovery that is slightly more elegant (I am probably repeating what some already know...but I think its great :-)

Is is not necessary to use a button to trigger the post back inside the panel. I updated a hidden input field with a value, and then submitted thehidden field iteself with __doPostBack, and it worked great. I needed a hidden field to pass in a unique ID anyway, so the panel would know how to refresh itself.

Inside the UpdatePanel:

<input id="txtGroupID" type="hidden" runat="server" onserverchange="txtGroupID_ServerChange" />

JS code:

txt = $get("<%=this.txtGroupID.ClientID %>");
txt.value = somevalue;
__doPostBack("<%=this.txtMatGroupID.UniqueID %>","");



Douglas Smith:

Where is the best place to find documentation and syntax for the built-in ASP.NET and AJAX JS functions and calls? For example, I did not know about $get or $addHandler functions.

The ASP.NET AJAX documentation does document all of these functions. You'd have to know where to look, though. All of the $-prefixed functions seem to be documented in the Sys.UI namespace here:

http://ajax.asp.net/docs/ClientReference/Sys.UI/default.aspx

Browsing through the source code helps find the undocumented stuff.


That will trigger an asynchronous post back, but no event will be raised on the server with that control as the target. You probably want to execute some code to modify the controls inside the update panel or there'd be little point in triggering the asynchronous post back. That's why I used a button control in the example I gave you. If all you want to do is trigger the asynchronous post back and don't care about raising a specific event on the server, you could use the ID of the update panel control as the event target. To me, that would be stating the intention of what you're trying to do a little clearer.

If you don't want to use a button but do want to raise an event on the server, you can use any control that implements IPostBackEventHandler as the event target. Those controls have a RaisePostBackEvent method that gets invoked when a post back is received with their ID as the event target. For button controls, they raise their Click event in that method. That's where your code gets to do its stuff. You could easily create an "empty" custom control that didn't render anything, but could be used as the event target. (I tried using the page control for this, but there's code that prevents you from registering the page as an asynchronous post back trigger.)

It'd be nice if the UpdatePanel control itself implemented IPostBackEventHandler and raised some sort of custom event on the server that let you do this without having to write much custom code. You could simulate this a bit by putting some code inside one of the event handlers on your page and checking to see if the ScriptManager control's AsyncPostBackSourceElementID is the ID of the UpdatePanel control you used as the event target. If so, execute your custom code.

Hope this helps.