Mitesh Machhi
Mitesh Machhi

Reputation: 203

Apply Jquery Function in click event of Link button (in code behind)

this is another question that I want to know that how to apply any jQuery function on onclick() event of Linkbutton.

I have a one Linkbutton and I want to set below jQuery function when linkbutton is clicked.

<önclick="TINY.box.show({
    iframe:'User_News.aspx',
    boxid:'frameless',
    width:250,
    height:250,
    fixed:false,
    maskid:'bluemask',
    maskopacity:40,
    closejs:function(){closeJS()}
})"
style="color: #0000FF; font-size: medium; height: 28px;"
id="l1" 
runat="server">

This function gives me a popup message. So how to get this popup when linkbutton is clicked?

Upvotes: 2

Views: 12351

Answers (2)

Adil
Adil

Reputation: 148180

You can bind the javascript function to linkbutton and it will show popup on click

<asp:LinkButton id="lnk" runat="server" OnClientClick="ShowPopUp();">

if you have linkbutton as id you can use jquery to bind script

$('#linkbutton').click(ShowPopUp);

if you have linkbutton as class you can use jquery to bind script

$('.linkbutton').click(ShowPopUp);  


function ShowPopUp(){
  TINY.box.show({
  iframe:'User_News.aspx',
  boxid:'frameless',
  width:250,
  height:250,
  fixed:false,
  maskid:'bluemask',
  maskopacity:40,
  closejs:function(){closeJS()}
  });
}

Upvotes: 3

Dipak
Dipak

Reputation: 12190

include jquery library - https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js

Considering Linkbutton as classname add this in Script tag -

$(function(){
  $('.Linkbutton').on('click', function(){
    $('#frameless').show();
  });
});

Upvotes: 1

Related Questions