By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,002 Members | 2,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,002 IT Pros & Developers. It's quick & easy.

how to call JavaScript function in user control ?

P: 1
simply i take one user control and register it in one page

now in this page i write a JavaScript function like this
Expand|Select|Wrap|Line Numbers
  1. function sethere()
  2.      {         document.getElementById('<%=(test1.FindControl("TextBox1")).ClientID %>') = document.getElementById('<%=(test3.FindControl("TextBox1")).ClientID %>').value;
  3.     }

now how to call it in user control,user control like this;
Expand|Select|Wrap|Line Numbers
  1. <ctrltest:test ID="test1" runat="server"/>
i tried this it not working;

Expand|Select|Wrap|Line Numbers
  1. <ctrltest:test ID="test1" runat="server" Onkeyup="sethere();"/>
i done only written above
Jun 19 '10 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,731
Why isn't it working?
What error message are you getting?

Oh wait, maybe it's because you're not setting the value of the first TextBox to the value of the second TextBox...

It should be:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('<%=(test1.FindControl("TextBox1")).ClientID %>').value = document.getElementById('<%=(test3.FindControl("TextBox1")).ClientID %>').value;
You should try using the JavaScript debugging tools that come with Internet Explorer 8. if you don't like Internet Explorer (which I can completely understand) you could use FrieFox's FireBug tool to debug the JavaScript. If you don't want to use FireFox then you'll have to use the debugging tools that come with your browser of choice...and if they don't come with one built in then search for one :)

Jun 25 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.