adding events at run time

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
In that case, take Steve's advice!

--
HTH,

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