inutan
inutan

Reputation: 10888

.Net - call client side and server side method on click of asp:LinkButton

I have an asp:LinkButton which require following -
- call jQuery to open link url in another tab of current browser
- then call server side method to perform some logging stuff

Please guide me for a

Thank you!

Upvotes: 0

Views: 319

Answers (1)

xDaevax
xDaevax

Reputation: 2022

Having Javascript make a call like:

window.open("http://www.google.com");

will always run the risk of being caught by a popup blocker. Is there a reason why you can't just set target="_blank" on the <a> tag?

As far as calling a server-side method without doing a postback, it's not possible. You could use JQuery's ajax function to make a call to a server side method where the page doesn't refresh, but a post-back must still occur, whether it is visible to the user or not.

Here is what that looks like:

$.ajax({
  type: 'POST',
  url: "http://www.yourdomain.com/pageToPostTo.aspx",
  data: "your data here",
  success: function(data) {
     alert("It worked");
  },
  dataType: "json"
});

Upvotes: 1

Related Questions