Reference control in user control

  • Thread starter Thread starter Leonardo Santos-Macias
  • Start date Start date
L

Leonardo Santos-Macias

I need a better way to reference a control using javascript from inside a
user control. I need the suer control to know about the name of the user
control vaiable upon use.

i.e. document.getElementById("my_discussionPanel_imgExpand").src = ...

The above does work fine if the class that uses the user control call it
my_discussionPanel (imgExpand is a control inise the suer control)

The problem is that this is not very general since the name of the user
control variable could be different.

i.e. a class defines

Dim your_newDiscussionPanel as DiscussionPanel

then

the declaracion in the user control

document.getElementById("my_discussionPanel_imgExpand").src

will not be valid

Is there any other way to do this???

Thanks

Leonardo
 
Leonardo,

I never did that, however I think using the "properties", property and than
the Id or something can do what you want (I am now not sure what is used
already in the viewstate, so have a look yourself)

In this sample I add a piece of JavaScript, however AFAIK you can use any
attribute
\\\
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Me.Button1.Text = "Send Mail"
Me.Button1.Attributes("onClick") =
"window.location='mailto:[email protected]?subject=Cor demo&body=I hope this
helps?';"
End If
End Sub
///
I hope this helps?

Cor
 

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

Back
Top