I have a ASP.NET Web Application using VB.NET in Visual Studio 2010 with 2012 Volume 1 (CLR 4.0). I have a button inside an UpdatePanel in an item template, but I cannot refer to it in the server code. The page source is:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SimpleExample.aspx.vb" Inherits="DataPAEnterpriseWeb.SimpleExample" %> <%@ Register Assembly="Infragistics4.Web.v12.1, Version=12.1.20121.1005, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.NavigationControls" TagPrefix="ig" %> <!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></title> </head> <body> <form id="form1" runat="server"> <div> <ig:WebExplorerBar ID="WebExplorerBar1" runat="server" Width="250px"> <Groups> <ig:ExplorerBarGroup GroupContentsHeight="" Text="Categories" Expanded="True"> <Items> <ig:ExplorerBarItem Text="Item" TemplateId="TreeViewTemplate"> <Template> <asp:UpdatePanel ID="TreeViewUpdatePanel" runat="server"> <ContentTemplate> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> </ContentTemplate> </asp:UpdatePanel> </Template> </ig:ExplorerBarItem> </Items> </ig:ExplorerBarGroup> </Groups> <AutoPostBackFlags ItemClick="Off" /> </ig:WebExplorerBar> </div> </form> </body> </html>
However, The following:
Public Class SimpleExample Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Button1.Text = "OK" End Sub
End Class
Gives the following error "'Button1' is not declared. It may be inaccessible due to its protection level.".
Hi Nick,
I apologize for not responding sooner. I followed the steps you suggested and was unable to reproduce the behavior you're describing. I added your code and markup to my sample and placed a breakpoint in tvCategories_NodeClick event. I added some test data for the nodes and then ran it. When I clicked on one of the nodes, the tvCategories_NodeClick event fired for me. It may help for you to add the following property to the WebDataTree even though I did not require it: OnNodeClick="tvCategories_NodeClick"
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed with IE8 and using version 12.1.20121.1005 in NetAdvantage for ASP.NET 2012 Volume 1.
If the project does show the product feature working correctly, this indicates a possible problem in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if I can provide any further assistance.
Hi Michael,
Any answer to my follow up question?
ThanksNick
Great stuff Michael, thanks, that worked a treat.
However, I now have another issue. The object I was adding was actually a WebDataTree (I used a button for a simple example). I need to respond to the NodeClick event of the WebDataTree, but now it is inside the ExplorerBar the event doesn't fire.
My code in the server code is as follows;
Public Class _default1 Inherits System.Web.UI.Page Dim WithEvents tvCategories As WebDataTree Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim upTemplate As UpdatePanel = Me.WebExplorerBar1.Groups(0).Items(0).FindControl("TreeViewUpdatePanel") tvCategories = upTemplate.FindControl("tvCategories") End Sub Private Sub tvCategories_NodeClick(sender As Object, e As Infragistics.Web.UI.NavigationControls.DataTreeNodeClickEventArgs) Handles tvCategories.NodeClick .... End Sub
and the relevant section of the page Markup is ...
<ig:WebExplorerBar ID="WebExplorerBar1" runat="server" Width="250px"> <Groups> <ig:ExplorerBarGroup GroupContentsHeight="" Text="Categories" Expanded="True"> <Items> <ig:ExplorerBarItem Text="Item" TemplateId="TreeViewTemplate"> <Template> <asp:UpdatePanel ID="TreeViewUpdatePanel" runat="server"> <ContentTemplate> <ig:WebDataTree ID="tvCategories" runat="server" AnimationDuration="300" AnimationEquationType="EaseInOut" EnableHotTracking="True" Height="100%" SelectionType="Single" Width="100%" EnableExpandOnClick="True" StyleSetName="Office2010Blue"> <AutoPostBackFlags NodeClick="On" /> </ig:WebDataTree> </ContentTemplate> </asp:UpdatePanel> </Template> </ig:ExplorerBarItem> </Items> </ig:ExplorerBarGroup> </Groups> <AutoPostBackFlags ItemClick="Off" /> </ig:WebExplorerBar>
Thanks very much again.Nick
Hello DataPA,
For our templated controls, you will need to programatically assign the variables to access them. Since templates may be used more than once, the controls in them cannot be defined at runtime. Please see the following code snippet for a demonstration of how to do this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim upTemplate As UpdatePanel = Me.WebExplorerBar1.Groups(0).Items(0).FindControl("TreeViewUpdatePanel") Dim button As Button = Nothing
If Not upTemplate Is Nothing Then button = upTemplate.FindControl("Button1") End If
If Not button Is Nothing Then button.Text = "OK" End IfEnd Sub
Please let me know if you need further assistance with this issue and I'll be glad to help.