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 5 6155
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
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
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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
...
|
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...
|
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 =...
|
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...
|
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:
...
|
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):...
|
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...
|
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,...
|
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...
|
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...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |