Link to home
Start Free TrialLog in
Avatar of Relegence
RelegenceFlag for Israel

asked on

Calling a javascript function with a parameter in a "ascx" control

Hello,

I am writing a 'ASCX' control that contains a text input and 2 images.
I am successfully calling javascript functions from the images, with the textbox's clientID
(onclick="javascript:increment('<%= txtUpDown.ClientID %>')")

But I do not know how to call a javascript function from the input, with the input's id.
I tried: onclick="javascript:clearText('<%= txtUpDown.ClientID %>')

But it doesn't work.

How can I do that?

Thanks,
Dana
ascx code
----------
 
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="updown.ascx.cs" Inherits="updown" %>
<table cellpadding="0" cellspacing="0" border="0" style="position:relative;top:11px;">
    <tr>
        <td>
            <input type="text" id="txtUpDown" runat="server" onclick="javascript:clearText('<%= txtUpDown.ClientID %>')" size="1" maxlength="2" />
            <table border="0" cellpadding="0" cellspacing="2" style="position:relative;left:24px;top:-26px;">
                <tr height="3px">
                    <td>
                        <img src="../images/arrUp.gif" onclick="javascript:increment('<%= txtUpDown.ClientID %>', <%=MaxVal%>)"/>
                    </td>
                </tr>
                <tr height="3px">
                    <td>
                        <img src="../images/arrDown.gif" onclick="javascript:decrement('<%= txtUpDown.ClientID %>', <%=MinVal%>)"/>
                    </td>
                </tr>
            </table>
        </td>
      
    </tr>
</table>

Open in new window

Avatar of gops1
gops1
Flag of United States of America image

remove "javascript:"
but are you doing some event on the textbox. Or when do you want to call this function?
and what is clearText doing?
ASKER CERTIFIED SOLUTION
Avatar of gops1
gops1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Relegence

ASKER

I used <input onclick="clearText(this.id)">
Thank you very much.
What I was trying to do was clearing the text in the textbox. Since there are some textboxes, used with some ascx controls, I didn't know how to refer to the textbox I need.