NibblyPig
NibblyPig

Reputation: 52952

How can I add an onclick to a generic control in asp.net?

I want the programmer to pass a Control to a method, and then I want to add an onclick to it. But control doesn't have an Attributes property. Is there an interface or something deriving from Control that I can use, to add an onclick attribute to it?

Note that I want to add a javascript onclick (clientclick?).

Upvotes: 1

Views: 186

Answers (2)

Anders Fjeldstad
Anders Fjeldstad

Reputation: 10834

Check out the System.Web.UI.WebControls.WebControl class - it inherits from System.Web.UI.Control and has an Attributes property.

Upvotes: 4

NibblyPig
NibblyPig

Reputation: 52952

D'oh I fixed it now, the solution is to use a WebControl rather than a Control.

Upvotes: 1

Related Questions