Solved

clientclick to validate server side input

Posted on 2014-01-30
1
352 Views
Last Modified: 2014-02-01
Hi Experts,

I have simple <form id="myform" runat="server" action="#">

<input id="mytxt1" runat="server" />
<input id="mytxt2" runat="server" />

<asp:button id="mybutton" onclick="do_stuff" onclientclick="something">
</form>

I need using either jquery or javascript to on clientclick code on client side :

1. get value of mytxt1
2  copy this value to mytxt2

Thanks a lot.
0
Comment
Question by:fpoyavo
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39823453
You would need to do something like:
    <form runat="server">

        <input id="mytxt1" runat="server" />
        <input id="mytxt2" runat="server" />

        <asp:Button id="mybutton" runat="server" OnClick="do_stuff" OnClientClick="return something();" Text="Click Me" />

    </form>

    <script type="text/javascript">
        function something() {
            document.getElementById('<%= mytxt2.ClientID %>').value = document.getElementById('<%= mytxt1.ClientID %>').value;
            return false;
        }
    </script>

Open in new window

Note: You'll need to take the return false; part out if you want the page to postback. I just added it in to stop the post back so you can see the copy take place.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…

776 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