how to call JavaScript function in user control ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vijay107
    New Member
    • Jun 2010
    • 1

    how to call JavaScript function in user control ?

    simply i take one user control and register it in one page

    now in this page i write a JavaScript function like this
    Code:
    function sethere()
         {         document.getElementById('<%=(test1.FindControl("TextBox1")).ClientID %>') = document.getElementById('<%=(test3.FindControl("TextBox1")).ClientID %>').value;
        }
    and

    now how to call it in user control,user control like this;
    Code:
    <ctrltest:test ID="test1" runat="server"/>
    i tried this it not working;

    Code:
    <ctrltest:test ID="test1" runat="server" Onkeyup="sethere();"/>
    i done only written above
    Last edited by Frinavale; Jun 25 '10, 03:07 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    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:
    Code:
    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 :)

    -Frinny

    Comment

    Working...