Apply Jquery Function in click event of Link button (in code behind)
11,511
Solution 1
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()}
});
}
Solution 2
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();
});
});
Author by
Mitesh Machhi
Updated on June 05, 2022Comments
-
Mitesh Machhi almost 2 years
this is another question that I want to know that how to apply any jQuery function on
onclick()
event ofLinkbutton
.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?
-
Roman almost 12 yearsThat doesn't even look like a valid tag, are you sure your code does anything?
-
Mitesh Machhi almost 12 yearsi have same like <li onclick="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">View Message </li>
-
Mitesh Machhi almost 12 yearsyes. i am using the .net with c#.
-
-
Adil almost 12 yearsOn which statement you get error and what is the error? Are you using asp.net ?
-
Mitesh Machhi almost 12 yearswhen i am writing this code in Script Function. and javascript function not work.
-
Adil almost 12 yearsOn which statement you get error and what is the error? Are you using asp.net ?
-
Mitesh Machhi almost 12 yearsyes sir. i am using c#.and when i call that function it does not work.
-
Adil almost 12 yearsc# does not mean that you are using asp.net. I want to know if you are using asp.net ?
-
Mitesh Machhi almost 12 yearsyes sir. i am using the asp.net. and for more info. to you that when i click on link button the code which you have suggest to me to write inside the function in not work. please tell me and it not call that jquery function.
-
Adil almost 12 yearsDo you know how to debug javascript? and what browser you have?
-
Mitesh Machhi almost 12 yearsi am use Alert("xxxx") and i use Google Chrome.
-
Adil almost 12 yearsThis is my answer to show how to debug please debug and tell me exact error you getting stackoverflow.com/questions/10573819/…
-
Mitesh Machhi almost 12 yearsnow, some changes i made and it looks like o.k. but also one problem that when click on linkbutton it display pop up sometime only for few seconds then after it goes back. it comes sometime only not for all time when i click on linkbutton.
-
Adil almost 12 yearsYou need to close popup to show it again because sometime it is minimized. Also try return fasle; from ShowPopUp() function and tell me what happens
-
Mitesh Machhi almost 12 yearssolved it brother and Thanks for Your suggestion and Chat with me to solve my problem.