Click here to Skip to main content
15,860,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I write the code for enter key:
XML
 <script type="text/javascript">
        function fncsave() {
            var k = (event.keyCode ? event.keyCode : event.which);
            //var k = event.keyCode;
            //alert(k);
            if (parseInt(k) == '13') {
 alert(k);
                document.getElementById('<%= imgbtnReply.ClientID %>').click();
            }

     }
</script>

and the button click event is:
XML
<asp:ImageButton ID="imgbtnReply" runat="server" ImageUrl="/tmpfimages/member/tmpf00151.png" CssClass="rply_adjst" OnClick="imgbtnReply_Click"  />
       <div class="areaspace"> </div>
       <asp:TextBox ID="txtReply"   CssClass="adtxtbx"  runat="server"  OnKeyPress="fncsave()"></asp:TextBox>

here the button click event didn't fire through javascript.Please assist me better.
Posted
Updated 3-Sep-15 21:36pm
v2

1 solution

When you use an imagebutton asp.net puts an img tag on the page as well as special javascript that listens for click events and runs its on code when it detects them. Calling any native click event on an image isn't going to trigger the code placed on the page by .net that handles the postback, you'll need to trigger that code yourself.

http://forums.asp.net/t/1366373.aspx?how+to+fire+a+image+button+click+event+using+javascript[^]
 
Share this answer
 
Comments
aiswarjya 4-Sep-15 7:07am    
this code which was i have written that was running perfectly in the page not in modal pop up-

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900