ajax and asp.net in user control

  • Thread starter Thread starter olivier
  • Start date Start date
O

olivier

Hi,

I want to use javascript (ajax) in User Control but to call
the object is difficult.

If my user control is called MyControl.
To use the object in javascript, i make,

Ex:
document.GetElementId("MyControl_textbox").value

Have you an idea to get the name of the user control asp.net
to instance my code javascript cause the same code javascript must to work
in other User control.

Thank's
Olivier
ps : excuse me for my poor english.
 
Salut,
*Hi,*
**
*I want to use javascript (ajax) in User Control but to call*
*the object is difficult.*
**
*If my user control *is called MyControl.
*To use the object in javascript, i make,*
**
*Ex:*
*document.GetElementId("MyControl_textbox").value*
**
*Have you an idea to get the name of the user control asp.net*
*to instance my code javascript cause the same code javascript must to work*
*in other User control.*
**
*Thank's*
*Olivier*
*ps : excuse me for my poor english.*

Je ne suis pas sûr d'avoir tout compris, si tu veux tu peux demander en
français.

Dans ton "code-behind", tu peux obtenir l'ID du widget que tu veux
adresser en JavaScript en utilisant la propriété "ClientID". Comme cette
ID dépend de la position (hierarchie) de ton User control dans la page,
c'est le seul moyen fiable!!

Par exemple:

string startUpScript = "<script type='text/javascript'>"
+ "document.getElementById('"
+ myTextBox.ClientID
+ "').value = 'Hello world';"
+ "</script>";

this.Page.ClientScript.RegisterStartupScript( this.Page.GetType(),
"startUpScript", startUpScript );

HTH,
Laurent
 
Back
Top