473,416 Members | 1,523 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,416 software developers and data experts.

[C#-WEB] Trouble finding controls in Update panel

Hi All,

I have a problem in finding control in a dynamically created updated panel. I have given the code below. Following is just a starting effort in a completely dynamic user control. I am experimenting before getting to the actual part. This is what I am trying to do:

* Create a tab container dynamically

* Create 5 tabs dynamically

* Add an update panel to each of the tabs

* Add a label to each of the update panels

* Add an OnLoad event to each of the tabs and change the contents of the label added

But I am not able to accomplish the last part, I am not sure how to access the label dynamically added to the update panel

I have given the code below. Please help me in this regard.


Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.HtmlControls;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Xml.Linq;
  13. using AjaxControlToolkit;
  14.  
  15. public partial class EvaluationsWidget : System.Web.UI.Page
  16. {
  17.    protected string[] tabnames = {"All","Contact Centers","Networks","Technology Planning"};
  18.  
  19.     protected Label lbl;
  20.  
  21.     protected void Page_Load(object sender, EventArgs e)
  22.      {
  23.           ArrayList al = new ArrayList();
  24.  
  25.           for (int i = 0; i < 20; i++)
  26.           al.Add(i.ToString());
  27.  
  28.           TabContainer tabContainer = new TabContainer();
  29.           tabContainer.ID = "tbContainerMain";
  30.           tabContainer.Width = 500;
  31.  
  32.           for (int i = 0; i < tabnames.Length; i++)
  33.           {
  34.               TabPanel tabPanel = new TabPanel();
  35.               tabPanel.ID = "evaluationsPanel" + i.ToString();
  36.               tabPanel.HeaderText = tabnames[i];
  37.               tabPanel.Load += new EventHandler(tabPanel_Load);
  38.  
  39.               UpdatePanel updPanel = new UpdatePanel();
  40.               updPanel.ID = "evaluationsUpdatePanel" + i.ToString();
  41.               updPanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
  42.  
  43.               lbl = new Label();
  44.               lbl.ID = "lbl" + i.ToString();
  45.               lbl.Text = "Label " + i.ToString();
  46.               updPanel.ContentTemplateContainer.Controls.Add(lbl);
  47.  
  48.               tabPanel.Controls.Add(updPanel);
  49.               tabContainer.Controls.Add(tabPanel);
  50.           }
  51.  
  52.           form1.Controls.Add(tabContainer);
  53.       }
  54.  
  55.       void tabPanel_Load(object sender, EventArgs e)
  56.       {
  57.           TabPanel tbPanel = (TabPanel)sender;
  58.  
  59.           //This doen't work, I need help here
  60.           this.lbl.Text = "Clicked";
  61.        }
  62.     }
  63.  


Thanks,

Karthik
Jul 31 '08 #1
4 3463
TTCEric
26
You need a 'Handles TabControl.OnLoad' appended to the end of the function signature like this

private sub MyTabControl(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyTabControl.OnLoad
Jul 31 '08 #2
Hi Eric,

Thank you for your reply. What you've said is for VB. Net. I looked and found out that "handles" keyword and its functionality isn't available in C#. And I also found out that "AutoEventWireup" should be set to true in C# as "handles" cannot be used in C#.

I have set auto event wireup to true in my page, Still it doesn't work. Please note that the label is created dynamically and added to the update panel. How am I supposed to access that label in the update panel?

Thanks again for replying
Jul 31 '08 #3
TTCEric
26
Oops. Didnt notice it was C#.

Ok, I found a link related to what you need. A good google keyword search is C# Event Handling. There are actually several ways to handle events in C#. This one I found most easier to follow:

http://www.c-sharpcorner.com/UploadF...ginCSharp.aspx
Jul 31 '08 #4
Thanks a lot for your replies Eric. I was able to solve the problem! Thanks again!
Jul 31 '08 #5

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

Similar topics

2
by: rodchar | last post by:
hey all, i saw an update panel example one time where they put a button outside the update panel and a textbox inside the panel and setup a trigger on the update panel to update when the button...
3
by: ma | last post by:
Hello, I have two update Panel in my page. I want to update one of these update panels from another one. How can I do this? How can I force the whole page to be updated from a button inside an...
1
by: suddy | last post by:
Hi, I've a web app, with multiple user controls on my page myPage.aspx. I've used Asp.net 2.0 ajax update panel which partially updates its contents on a command button click, due to this I...
1
by: durga2005 | last post by:
hi i have a textbox and regular expression validator control .i have placed these control inside update panel. just im validating the textbox with regular expression validator control when i...
1
by: John Kotuby | last post by:
Hi guys, I have finally added the AJAX extensions to my ASP.NET project in VS 2005 and VB. It was far simpler than I had anticipated, and I wondering why I didn't use the Update Panel sooner. ...
1
by: sweatha | last post by:
I have designed the login form with 3 panels. In the first panel I have the login verification such as login id, password, login button and forgot password link button. In the second panel I have...
0
by: AdonisL81 | last post by:
Hello, I am new to .NET I am having trouble with a asp update panel and Gridview. The Gridview control is inside the update panel and I am trying to have the gridview update from a form button....
2
by: =?Utf-8?B?TUNN?= | last post by:
I have an asp.net page that contains an update panel. Within the update panel, controls get added dynamically. During partial page post backs the controls within the panel will change. I have a...
7
by: Marknut | last post by:
I have an AJAX UpdatePanel that contains multiple dropdownlists, a button, and an ASP Panel (which contains dropdownlists and textboxes). On button_click I want to enable the ASP panel, but it is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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.