Hi all,
        I've figured out what the solution to my problem is.  The
dynamically created controls must always be present in the page for the
event to be fired. This means that you must re-create them at run-time,
every time, for their event to fire.  So whatever routine you use to
create the dynamic buttons, go through it in your page_load subroutine
to recreate them, then your events will fire properly.

Matthew Small
IT Supervisor
Showstopper National Dance Competitions
3660 Old Kings Hwy
Murrells Inlet, SC 29576
843-357-1847
http://www.showstopperonline.com
 

-----Original Message-----
From: Matthew Small [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, September 24, 2002 10:41 AM
To: dotnet
Subject: RE: Dynamically creating LinkButton and getting error

Hi - 
        Sorry to keep bringing this up, but I am having no luck
programmatically creating linkbuttons.

I am not getting any errors, but the links that are created not do call
the subroutine that I want them to:



' dbrow is a datarow in the rows collection of a datatable

Link = new LinkButton
Link.Text = dbrow.item("categoryname")  
Link.CommandName = "CatId"
Link.CommandArgument = dbrow.item("categoryid")
AddHandler Link.Command, AddressOf SelectItem


In this case, I want the linkbuttons to call the subroutine 

" Sub SelectItem (sender As Object, e As CommandEventArgs) "

>From there I can handle it.  However, if they are calling any
subroutine, I can't figure out what it is.

Please help, thank you.


Matthew Small
IT Supervisor
Showstopper National Dance Competitions
3660 Old Kings Hwy
Murrells Inlet, SC 29576
843-357-1847
http://www.showstopperonline.com
 

-----Original Message-----
From: Patrick Steele [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 23, 2002 1:24 PM
To: dotnet
Subject: RE: Dynamically creating LinkButton and getting error

Ok, if you're creating controls programatically in code (like in your
original email), you'll want to use AddHandler:

AddHandler Link.Command, AddressOf SelectItem

If you want to assign parameters inside the HTML tag, use:

<asp:LinkButton Command="SelectItem" ... />

Assuming SelectItem is a standard event:

Public Sub SelectItem(sender as object, e as EventArgs)
        dim lb As LinkButton = CType(sender, LinkButton)
        dim CatID as String = lb.CommandArgument

        ' do stuff with CatID
End Sub

---
Patrick Steele ([EMAIL PROTECTED])
Lead Software Architect
Image Process Design



-----Original Message-----
From: Matthew Small [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 23, 2002 1:15 PM
To: dotnet
Subject: RE: Dynamically creating LinkButton and getting error


Well, I did that before I wrote to the list.  I don't understand why I
am getting this error. I don't seem to understand the process of getting
a linkbutton to call a subroutine with a passed parameter.  I thought
that if I gave a subrountine name to the OnCommand property then when
the link was clicked, the form would submit, the subroutine named in the
OnCommand property would be executed, the parameters given in the
CommandArgument property would be passed to the subroutine.  What am I
doing wrong? This error acts as if though I am trying to override the
method.  Perhaps, I am, I don't know all that much about .NET.  However,
this just isn't working for me, I don't know why.

Matthew Small
IT Supervisor
Showstopper National Dance Competitions
3660 Old Kings Hwy
Murrells Inlet, SC 29576
843-357-1847
http://www.showstopperonline.com
 

-----Original Message-----
From: Patrick Steele [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 23, 2002 12:58 PM
To: dotnet
Subject: RE: Dynamically creating LinkButton and getting error


See the documentation for LinkButton.CommandArgument Property.  It gives
an example of what I think you're looking for.  If it's not clear, just
send a follow-up.

---
Patrick Steele ([EMAIL PROTECTED])
Lead Software Architect
Image Process Design



-----Original Message-----
From: Matthew Small [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 23, 2002 12:51 PM
To: dotnet
Subject: RE: Dynamically creating LinkButton and getting error


SelectItem is a subroutine that I call.  I'm not really confident of how
OnCommand works.  I thought it was like OnClick except it passes
parameters.

What I need to do is have a linkbutton that, when clicked, calls
SelectItem(CategoryId as String) or some variation of the function that
will let me determine which link was clicked.


Matthew Small
IT Supervisor
Showstopper National Dance Competitions
3660 Old Kings Hwy
Murrells Inlet, SC 29576
843-357-1847
http://www.showstopperonline.com
 

-----Original Message-----
From: Patrick Steele [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 23, 2002 12:45 PM
To: dotnet
Subject: RE: Dynamically creating LinkButton and getting error

I guess I'd need to know exactly what you want with this statement:

Link.OnCommand="SelectItem"

Do you have a function or sub called "SelectItem" that you want to be
called whenever the Command event fires?  Or are you trying to set up
some client-side javascript stuff for that control?

---
Patrick Steele ([EMAIL PROTECTED])
Lead Software Architect
Image Process Design



-----Original Message-----
From: Matthew Small [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 23, 2002 12:37 PM
To: dotnet
Subject: RE: Dynamically creating LinkButton and getting error


Can you break that down for me?

Matthew Small
IT Supervisor
Showstopper National Dance Competitions
3660 Old Kings Hwy
Murrells Inlet, SC 29576
843-357-1847
http://www.showstopperonline.com
 

-----Original Message-----
From: Patrick Steele [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 23, 2002 12:29 PM
To: dotnet
Subject: RE: Dynamically creating LinkButton and getting error

Assuming the "SelectItem" is a VB.NET procedure on the server, you
should use:

AddHandler Link.Command, AddressOf SelectItem

---
Patrick Steele ([EMAIL PROTECTED])
Lead Software Architect
Image Process Design



-----Original Message-----
From: Matthew Small [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 23, 2002 12:19 PM
To: dotnet
Subject: Dynamically creating LinkButton and getting error


Hi -
        I am dynamically creating a linkbutton.  When I run the page, I
get an error that I do not understand.  Can you help me please?


Code:
Dim Link as LinkButton

...

Link = new LinkButton
Link.Text = dbrow.item("categoryname")
Link.CommandName = "CatId"
Link.CommandArgument = dbrow.item("categoryid")
Link.OnCommand="SelectItem"

...


Error:

Compilation Error 
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately. 

Compiler Error Message: BC30390:
'System.Web.UI.WebControls.LinkButton.Protected Overridable Overloads
Sub OnCommand(e As System.Web.UI.WebControls.CommandEventArgs)' is not
accessible in this context because it is 'Protected'.

Source Error:

 

Line 91:                        Link.CommandName = "CatId"
Line 92:                        Link.CommandArgument =
dbrow.item("categoryid")
Line 93:                        Link.OnCommand="SelectItem"
Line 94:                                        
Line 95:                        Cell = new TableCell
 

Source File: C:\Inetpub\asp.office\shoponline\cart.aspx    Line: 93


Thank you for you help.



Matthew Small
IT Supervisor
Showstopper National Dance Competitions
3660 Old Kings Hwy
Murrells Inlet, SC 29576
843-357-1847
http://www.showstopperonline.com
 

-----Original Message-----
From: Thomas V. Nielsen [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 23, 2002 10:56 AM
To: dotnet
Subject: RE: Finding Image Height/Width with VBScript?

Hmm how about setting it to 100% ?


<Thomas/>


---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/





---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/



---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/






---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/



---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/






---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/



---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/






---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/



---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/






---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/






---
You are currently subscribed to dotnet as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/


Reply via email to