Solved

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

Posted on 2007-11-26
6
4,132 Views
Last Modified: 2012-08-14
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

0
Comment
Question by:Relegence
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 17

Expert Comment

by:gops1
ID: 20349524
remove "javascript:"
0
 
LVL 17

Expert Comment

by:gops1
ID: 20349533
but are you doing some event on the textbox. Or when do you want to call this function?
0
 
LVL 17

Expert Comment

by:gops1
ID: 20349543
and what is clearText doing?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 17

Accepted Solution

by:
gops1 earned 400 total points
ID: 20349549
you can pass the id by any of the mouse or keboard event:

<input onclick="clearText(this.id)">

but instead you can pass the object itself by just saying "this"
<input onclick="clearText(this)">

Not sure what you want to do.
0
 

Author Closing Comment

by:Relegence
ID: 31410964
I used <input onclick="clearText(this.id)">
0
 

Author Comment

by:Relegence
ID: 20349601
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.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question