multiple attributes.add on a link button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to add 2 'onclick' events to a link button but, of course, the
javascript wont work.

In other words:

linkbutton.Attributes.Add("onClick", "MyFunction1();")
linkbutton.Attributes.Add("onClick", "MyFunction2();")

How would i get this to work? (keeping in mind that I cannot combine
MyFunction1 and 2 together) Is there another event other than onclick I can
use?

Thanks in advance.
 
Hi,

Call one function after the other in a single event invocation itself as in:

linkbutton.Attributes.Add ("onClick", "MyFunction1(); MyFunction2();")

I want to add 2 'onclick' events to a link button but, of course, the
javascript wont work.

In other words:

linkbutton.Attributes.Add("onClick", "MyFunction1();")
linkbutton.Attributes.Add("onClick", "MyFunction2();")

How would i get this to work? (keeping in mind that I cannot combine
MyFunction1 and 2 together) Is there another event other than onclick I can
use?

Thanks in advance.
 
Thanks for your reply.

The problem I have is that I am conditionally adding these attributes and
sometimes only MyFunction1() OR MyFunction2() OR both together are needed.
This could get complicated so I was looking for some alternative that would
allow me to add both separately.
 
You can always append further function names as in:

linkbutton.Attributes.Add ("onClick", "MyFunction1();")
If (...) Then
linkbutton.Attributes.Item ("onClick") &= ";MyFunction2();"
End If

If the specified key doesn't exist in Item collection, Nothing will be
returned.

Thanks for your reply.

The problem I have is that I am conditionally adding these attributes and
sometimes only MyFunction1() OR MyFunction2() OR both together are needed.
This could get complicated so I was looking for some alternative that would
allow me to add both separately.
 
Shiva said:
You can always append further function names as in:

linkbutton.Attributes.Add ("onClick", "MyFunction1();")
If (...) Then
linkbutton.Attributes.Item ("onClick") &= ";MyFunction2();"
End If

If the specified key doesn't exist in Item collection, Nothing will be
returned.
Exactly what I was looking for. Thanks!
 
Back
Top