Solved

jquery onclick and server side.

Posted on 2013-05-22
3
676 Views
Last Modified: 2013-05-23
Trying use a jquery onclick event and serverside button submission one work without the other. need both to work at the same time.

  $(document).ready(function () {
           $('[id$="txtSubmit"]').each(function (index, button) {
           var oldClickHandler = button.onClick;
           $(button).click(function (clickEvent) {
alert("work");
   oldClickHandler.call(button, clickEvent);
           });
       });
       });

Open in new window


<asp:Button runat="server"    ID="txtSubmit" Text="Next" />
 Protected Sub txtSubmit_Click(sender As Object, e As EventArgs) Handles txtSubmit.Click
function work here
response.write("function started")
End sub
0
Comment
Question by:sevensnake77
[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
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 39190288
IDs MUST be unique so either use a class or if you only have one button, remove the each and have

$(document).ready(function () {
  var but = $("#txtSubmit"); // or $("<%= txtSubmit.ClientID %>");
  but.get(0)._onclick=but.get(0).onclick; // save the DOM onclick
  but.on("click",function (e) {
    alert("work");
     this._onclick.call(this, e);
   });
});

Open in new window

0
 
LVL 9

Author Comment

by:sevensnake77
ID: 39190946
Well that is the funny part I use the id and it was unique and it worked then it just stopped working. Only the jquery works first and not the server side. Or if I remove the jquery then the client side work. crazy.
0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 39191856
Thanks for the response I resolved everything to javascript and using document.elemenbyid.  on the server side passing values to hidden input textbox.
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
WordPress can be pretty daunting, especially for a beginner, so I thought it might be a good idea to write an article to show how easy it is to get started in WordPress and to design a custom theme.  The first step is to check with your hosting comp…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …

696 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