javascript problem

M

Morten

Hi!

I'm trying to have a button open a Window using javascript. I want to open a
window pointing to a specific URL and close it imediately afterwards. I've
registered a javascript block in my code-behind file and used this code:

Button1.Attributes.Add("onclick", "javascript:popup()");
to have the button execute the script. Now my problem is that I need to
specify a parameter for the javascript function. More precisely I want the
content of a textbox to be sent to the javascript:

Button1.Attributes.Add("onclick", "javascript:popup(TextBox1.Text)");
but I can't figure out how to do this.

Hope someone can help.

Morten
 
C

carion1

myButton.Attributes.Add("onClick", "alert(document.theForm." + myText.ID +
".value);");

Instead of an alert you can call your function.
 
T

The Crow

myText.ClientID is more correct. (if myText is contained in a naming
container control other then Page itself, its id will be added after its
parent seperated with _)
 

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

Top