473,406 Members | 2,369 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,406 software developers and data experts.

LinkButton in a placeholder control

Hi

The code below is adding a dynamicly created LinkButton to a
placeholder control.
When I click the LinkButton it should call attLink_Click(), but it
dosen't happen.
What is wrong? Please help.

By the way, I'm using VS.NET 2005
//Code creating the LinkButton
LinkButton attLink = new LinkButton();
attLink.ID = "dummy";
attLink.Text = "blablabla";
attLink.Click += new EventHandler(attLink_Click);
phUploadedFiles.Controls.Add(attLink);

//Eventhandler
void attLink_Click(object sender, EventArgs e)
{
throw new Exception("The method or operation is not
implemented.");
}

Jan 2 '06 #1
2 2273
The linkbutton needs to be re-added to the placeholder control during
postback on or before Page_Load. If you are adding this linkbutton within
an another event handler, or when !PAge.IsPostback, you'll need to do some
work to re-add it if it was previously added.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

<eg****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi

The code below is adding a dynamicly created LinkButton to a
placeholder control.
When I click the LinkButton it should call attLink_Click(), but it
dosen't happen.
What is wrong? Please help.

By the way, I'm using VS.NET 2005
//Code creating the LinkButton
LinkButton attLink = new LinkButton();
attLink.ID = "dummy";
attLink.Text = "blablabla";
attLink.Click += new EventHandler(attLink_Click);
phUploadedFiles.Controls.Add(attLink);

//Eventhandler
void attLink_Click(object sender, EventArgs e)
{
throw new Exception("The method or operation is not
implemented.");
}

Jan 2 '06 #2
The linkbutton is added in another event handler, so that is where the
error is.
Thanks for your answer.

Jan 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
3
by: CodeRazor | last post by:
Hi, I am trying to dynamically create linkbuttons. They need an event handler, so i can respond to the user's click. I try to add the eventhandler on the fly, but when i click on the link, the...
1
by: Dan | last post by:
I have an asp.net page default.aspx with a user control and a placeholder control. <html> <body> <form id="myform" method="post" runat="server" /> <PageHeader:Header id="header1"...
1
by: Jo Inferis | last post by:
(Disclaimer : I'm pretty new to .NET, so please forgive me if this isn't 100% clear) I know Master pages are coming, but until then I've implemented a version of the page templating solution at...
1
by: ItNerd | last post by:
I have a placeholder in an aspx page that loads a control (.ascx). The aspx page's page_load event loads the placeholder and sets its visibility to false. There is a datagridcommandevent that...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
5
by: studio60podcast | last post by:
I have an ASP:Placeholder and I'm trying to populate with Label controls from the code behind after a button click, essentially creating a list of selections. But each time I click the button,...
0
by: OceanBreeze | last post by:
I have added a LinkButton to a table cell programmatically inside the Page_Load method. I also added a custom event to that link button. The same custom event is valid for all the link buttons. The...
5
by: Peter Larsen [CPH] | last post by:
Hi, The following sample shows a LinkButton in the HeaderTemplate of a Repeater control. The problem is that i'm not able to access the linkbutton in code (in the cs file) as long as the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...

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.