adding events at run time

G

Guest

I'm trying to add an event handler to the on click event of an existing link
button.
here is the code:
Dim thscc As LinkButton
dWrk = dtrCal("calDate")
thscc.onClick = New EventHandler(AddressOf cc_onClick)
the .onClick is erroring out. I think i have the right idea but , ....
also if i add an event to an existing item will it need to be recreated on
each post back like a dynamicly created link button?
thanks
kes
 
K

Kevin Spencer

The code you posted doesn't refer to an existing LinkButton. You haven't
instantiated one, just created a variable of that type. You didn't mention
what error message you're getting, but my guess would be "Object reference
not set to an instance of an object."

In addition, the LinkButton must be added to the Page Controls somehow.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
 
G

Guest

thanks for replying,
(Sorry you are correct i missed a line in my posting:
thscc = FindControl("cc" & i.ToString) )

I haven't even got that far. It will not compile, but the following does
work, with the extra line.
thscc.Text = dWrk.Day.ToString
thscc.CommandName = "cc_CMD"
thscc.CommandArgument = dtrCal("calDate")
Given that i got this far how do it set the onClick event or create it?
thanks (again)
kes
 
K

Kevin Spencer

In that case, take Steve's advice!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top