0

I've got a Web control called Fou.ascx and it has a java script function called DoFou(message). In my web Page I want to click a button, which is on the page and not part of the web control, and have it execute DoFou and pass in the message parameter. The web page has an instance of the web control Fou.

How can I do this?

thanks

1 Answer 1

0

If the button is a server control, in the code behind you can do something like

myButton.Attributes.Add("onClick", "doFou('" + myMessage + "');");

If the button is not a server control and assuming that myMessage is accessible in the ascx you can do something like

<input type="button" onclick='<%= "doFou(\"" + myMessage + "\");" %>' value="myButton" />
3
  • doesn't seem to work, when I view the page's source I don't see DoFou and all DoFou has is alert(messsage); and nothing pops up. Commented Jan 28, 2011 at 17:17
  • i did attribute.add suggestion, i see it in the button's onclick Commented Jan 28, 2011 at 17:18
  • ahh, my control was invisible, when I changed it to visible it works] Commented Jan 28, 2011 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.