473,506 Members | 16,951 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help in asp.net addhandler

Hi, I create an dynamic command button like that:
buttonCmd= New Button
buttonCmd.ID = "IDBTN1"
buttonCmd.Text = "Test"
AddHandler buttonCmd.Click, AddressOf MessageClick

I have this click sub:
Sub MessageClick(ByVal sender As Object, ByVal e As System.EventArgs)
'Do something
End Sub

For the first try I create this dynamic button on time in the form load
between
If Not Page.IsPostBack Then

Jul 21 '05 #1
5 6181
Sorry I hit the Post buttun!

Here is the next part of my answers...

Like I said, I put the dynamic button in the
if not page.isPostBack then
'create the button
end if

When I hit the button, nothing append and my button disapear. I think that
my buttun is lost in the postbak add for that reason the event added by the
addhandler is not fired...

I change my code to initialize the button and add the handler in the
page_load without the if not page.isPostBack limitation.
When I start the web page I I click on the button I receive this error:

Multiple controls with the same ID 'IDBTN1' were found. FindControl requires
that controls have unique IDs.

Why? The postback is not supposed to lost this control? How can I fire my
event?

Thanks for your help
Jul 21 '05 #2
Pierre,

Dynamically created controls need to be re-created in code upon every
request to the page AND it has to be re-created before the Page_Load() event
fires, I suggest you override the Init() and put your code to create the
button in that method.

HTH,
Jorge

"Pierre" wrote:
Sorry I hit the Post buttun!

Here is the next part of my answers...

Like I said, I put the dynamic button in the
if not page.isPostBack then
'create the button
end if

When I hit the button, nothing append and my button disapear. I think that
my buttun is lost in the postbak add for that reason the event added by the
addhandler is not fired...

I change my code to initialize the button and add the handler in the
page_load without the if not page.isPostBack limitation.
When I start the web page I I click on the button I receive this error:

Multiple controls with the same ID 'IDBTN1' were found. FindControl requires
that controls have unique IDs.

Why? The postback is not supposed to lost this control? How can I fire my
event?

Thanks for your help

Jul 21 '05 #3
ok, but the example I post is verry simple, but in the real life, the number
of command button are deternimed by some querys to an SQL database in
function of the user logged in (form authentication).
Plus the command button are created in a cell of a static asp table. This
table is created before the Page_Init sub? I will be able to acces it and
populate it?

"Jorge L Matos [MCSD.NET]" wrote:
Pierre,

Dynamically created controls need to be re-created in code upon every
request to the page AND it has to be re-created before the Page_Load() event
fires, I suggest you override the Init() and put your code to create the
button in that method.

HTH,
Jorge

"Pierre" wrote:
Sorry I hit the Post buttun!

Here is the next part of my answers...

Like I said, I put the dynamic button in the
if not page.isPostBack then
'create the button
end if

When I hit the button, nothing append and my button disapear. I think that
my buttun is lost in the postbak add for that reason the event added by the
addhandler is not fired...

I change my code to initialize the button and add the handler in the
page_load without the if not page.isPostBack limitation.
When I start the web page I I click on the button I receive this error:

Multiple controls with the same ID 'IDBTN1' were found. FindControl requires
that controls have unique IDs.

Why? The postback is not supposed to lost this control? How can I fire my
event?

Thanks for your help

Jul 21 '05 #4
OK I make the test. I place the function that populate the static table and
create the dynamic button. All work good for acceding the static table to
when I hit the button a got the same errer :

Multiple controls with the same ID 'BTN11' were found. FindControl requires
that controls have unique IDs.

"Pierre" wrote:
ok, but the example I post is verry simple, but in the real life, the number
of command button are deternimed by some querys to an SQL database in
function of the user logged in (form authentication).
Plus the command button are created in a cell of a static asp table. This
table is created before the Page_Init sub? I will be able to acces it and
populate it?

"Jorge L Matos [MCSD.NET]" wrote:
Pierre,

Dynamically created controls need to be re-created in code upon every
request to the page AND it has to be re-created before the Page_Load() event
fires, I suggest you override the Init() and put your code to create the
button in that method.

HTH,
Jorge

"Pierre" wrote:
Sorry I hit the Post buttun!

Here is the next part of my answers...

Like I said, I put the dynamic button in the
if not page.isPostBack then
'create the button
end if

When I hit the button, nothing append and my button disapear. I think that
my buttun is lost in the postbak add for that reason the event added by the
addhandler is not fired...

I change my code to initialize the button and add the handler in the
page_load without the if not page.isPostBack limitation.
When I start the web page I I click on the button I receive this error:

Multiple controls with the same ID 'IDBTN1' were found. FindControl requires
that controls have unique IDs.

Why? The postback is not supposed to lost this control? How can I fire my
event?

Thanks for your help

Jul 21 '05 #5
Nothing more to help?

"Pierre" wrote:
OK I make the test. I place the function that populate the static table and
create the dynamic button. All work good for acceding the static table to
when I hit the button a got the same errer :

Multiple controls with the same ID 'BTN11' were found. FindControl requires
that controls have unique IDs.

"Pierre" wrote:
ok, but the example I post is verry simple, but in the real life, the number
of command button are deternimed by some querys to an SQL database in
function of the user logged in (form authentication).
Plus the command button are created in a cell of a static asp table. This
table is created before the Page_Init sub? I will be able to acces it and
populate it?

"Jorge L Matos [MCSD.NET]" wrote:
Pierre,

Dynamically created controls need to be re-created in code upon every
request to the page AND it has to be re-created before the Page_Load() event
fires, I suggest you override the Init() and put your code to create the
button in that method.

HTH,
Jorge

"Pierre" wrote:

> Sorry I hit the Post buttun!
>
> Here is the next part of my answers...
>
> Like I said, I put the dynamic button in the
> if not page.isPostBack then
> 'create the button
> end if
>
> When I hit the button, nothing append and my button disapear. I think that
> my buttun is lost in the postbak add for that reason the event added by the
> addhandler is not fired...
>
> I change my code to initialize the button and add the handler in the
> page_load without the if not page.isPostBack limitation.
> When I start the web page I I click on the button I receive this error:
>
> Multiple controls with the same ID 'IDBTN1' were found. FindControl requires
> that controls have unique IDs.
>
> Why? The postback is not supposed to lost this control? How can I fire my
> event?
>
> Thanks for your help

Jul 21 '05 #6

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

Similar topics

0
1461
by: Henrik Nordgren | last post by:
Im trying to build a simple chat app... here is the code: server visual basic code:-------------------------------------------------------------------------------- Public Class ChatServer ...
3
1448
by: Jeffrey A. Voigt | last post by:
Can someone take a quick glace at my code and tell me why my AutoPostBackHandler function does not get fired off at all? What I'm trying to do is get all of the Buttons and DropDownList controls...
7
4004
by: UGH | last post by:
I am adding image buttons dynamically and I need to add event handler when the user clicks on one of those image buttons which will have different id for reports. Here is my code LnkImage =...
7
1691
by: Tigger | last post by:
Dear Experts, I am working on ASP.NET. I have got a problem related to the usage of Javascript in ASP.NET. Please help. The story is the following: 1) I am developing an ASP.NET application. I...
2
2642
by: Sean Carey | last post by:
I converted a C# Upload app to VB.NET and am down to one error and was hoping someone could help me with te error. I would greatly appreciate help from anyone. Here is the error: ...
1
4317
by: treelife | last post by:
I'm getting and internal server error when | run the following mod_python script. I am actually trying to run Django. Script: from mod_python import apache def handler(req):...
2
1904
by: momo | last post by:
Hello Guys, I have a bit of a problem, I created a Dll called SecureQueryStringDll.dll and I had the dll put bin folder of my application first and it did not work so I then put it in the bin...
0
1385
by: richard | last post by:
OK, Im finished pulling my hair out and now I need help. I have created a VB class file for my custom paging, in it I create a table with 2 rows, in the rows I have linkbuttons for first page,...
3
3545
by: RobinS | last post by:
I'm trying to learn WPF and do it in VB instead of C#. (God forbid I should do *anything* the easy way. ;-) Here's something weird. On p162-3 of this book by Petzold (in C# of course) in an...
4
2339
by: Ty | last post by:
Hello all, I am creating a website in VS 2008 VB.net. On one of my pages I am using the Table control to make a type of calendar a IN/OUT board. The problem I found after I wrote all the code...
0
7103
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
7307
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
7370
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
5614
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,...
1
5035
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
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.