but i want to make it appear when a user clicks on the linkbutton but link button dont support javascript on client click so how can i manage this?
i want when i user clicks on the linkbutton that the div appears the code above is in main.master since i dont have head content place holder in other pages
but since it as oncliente click i think the code above (2nd box) is not need just need to create a function called the same name right? but how to create a func deirectly in source?
Well you're calling this code "verificalogincomprarartigo" in your client click event what does that do? If thats a function you might need to put () after it for the function to be called. Once the function is working you need to remember to put return
false; at the end otherwise a postback will occur.
You can also add the event with jQuery $('#linbuttonId').click(function() { $('#info').show() // Or whatever your trying to do. });
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="addToCart" CommandArgument='<%# Eval("ID") %>' OnClientClick="verificalogincomprarartigo" ><img src="imagens/Shopcart-Add_48.png" alt="" align="middle" border="0" /></asp:LinkButton>
<script type="text/javascript">
function verificalogincomprarartigo() {
$(document).ready(function () {
$("#info").hide();
$("#LinkButton1").click(function () {
$("#info").show().animate({ margin: 0 }, 4000).fadeOut();
});
});
return false //prevent the ASP.NET button from causing a postback in firefox http://bytes.com/topic/asp-net/answers/880146-javascript-function-linkbutton-not-firing-firefox-browser
}
</script>
however i forget that i have to check if a user is logged and and this messages just shows if a user is logged in i have a session var for that iduser (code behind) i have to serach a litle more to find how to do this
lb.Attributes.Add ("onclick","javascript:return verificalogincomprarartigo()");
you can see in rendred html it is rendered that onClientclick event
is rendred as onclick() event only
Please Dont't Forget to Mark As Answer if it helps you.
Custom watermark on PDF Thanks and Regards
Ravi Mathpal
lb.Attributes.Add ("onclick","javascript:return verificalogincomprarartigo()");
you can see in rendred html it is rendered that onClientclick event
is rendred as onclick() event only
but i cant solve like this:
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="addToCart" CommandArgument='<%# Eval("ID") %>' OnClientClick="verificalogincomprarartigo" ><img src="imagens/Shopcart-Add_48.png" alt="" align="middle" border="0" /></asp:LinkButton>
<script type="text/javascript">
function verificalogincomprarartigo() {
$(document).ready(function () {
$("#info").hide();
$("#LinkButton1").click(function () {
$("#info").show().animate({ margin: 0 }, 4000).fadeOut();
});
});
return false //prevent the ASP.NET button from causing a postback in firefox http://bytes.com/topic/asp-net/answers/880146-javascript-function-linkbutton-not-firing-firefox-browser
}
</script>
however i need to run only this function if a user is not logged in so i need a rsponse.write before this to check if user is logged in or not.
why you insist in lb.atributtes.add if i have a onclientclick property?
and how can i run a function here before this script to check if user is logged in
i have a ssesion var in condebihind on this button also in CommandName="addToCart" but i cant use this var Userid here since i'm not in codebind right?
If you use this you can check for session also you can add it conditonally
if(Session["UserID"]!=null)
{
lb.Attributes.Add ("onclick","javascript:return verificalogincomprarartigo()");
}
Please Dont't Forget to Mark As Answer if it helps you.
Custom watermark on PDF Thanks and Regards
Ravi Mathpal
If you use this you can check for session also you can add it conditonally
if(Session["UserID"]!=null)
{
lb.Attributes.Add ("onclick","javascript:return verificalogincomprarartigo()");
}
ok so way to do it in source only .
but the function verificalogincompraartigo stills on souce right?
hsl89
Member
476 Points
441 Posts
linkbutton javascript
Feb 28, 2011 05:46 PM|LINK
hi,
i have this on my main.master page
<script type = "text/jscript" > jQuery.noConflict(); jQuery(function ($) { $(document).ready(function () { $("#info").hide(); }); }); </script>i've to use no conflict function because i ahve another plugins take make it get error but with this no error so $ function works
the info is a message div see here what i want to do http://www.jankoatwarpspeed.com/post/2008/12/13/Animate-your-message-boxes-with-jQuery.aspx see blink effect
but i want to make it appear when a user clicks on the linkbutton but link button dont support javascript on client click so how can i manage this?
i want when i user clicks on the linkbutton that the div appears the code above is in main.master since i dont have head content place holder in other pages
RaviSM
Contributor
2622 Points
589 Posts
Re: linkbutton javascript
Feb 28, 2011 06:24 PM|LINK
lnkbtn.Attributes.Add("onclick","functionName()");
Try this
Custom watermark on PDF
Thanks and Regards
Ravi Mathpal
hsl89
Member
476 Points
441 Posts
Re: linkbutton javascript
Feb 28, 2011 08:37 PM|LINK
hi i'm doing this
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="addToCart" CommandArgument='<%# Eval("ID") %>' OnClientClick="verificalogincomprarartigo" ><img src="imagens/Shopcart-Add_48.png" alt="" align="middle" border="0" /></asp:LinkButton>and on code this:
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { ListViewDataItem currentItem = (ListViewDataItem)e.Item; LinkButton lb = (LinkButton)currentItem.FindControl("LinkButton1"); lb.Attributes.Add ("onclick","javascript:returnverificalogincomprarartigo()"); }but since it as oncliente click i think the code above (2nd box) is not need just need to create a function called the same name right? but how to create a func deirectly in source?
snagpoonage
Participant
1850 Points
471 Posts
Re: linkbutton javascript
Feb 28, 2011 09:17 PM|LINK
Well you're calling this code "verificalogincomprarartigo" in your client click event what does that do? If thats a function you might need to put () after it for the function to be called. Once the function is working you need to remember to put return false; at the end otherwise a postback will occur.
You can also add the event with jQuery $('#linbuttonId').click(function() { $('#info').show() // Or whatever your trying to do. });
hsl89
Member
476 Points
441 Posts
Re: linkbutton javascript
Feb 28, 2011 09:45 PM|LINK
i've solved this way:
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="addToCart" CommandArgument='<%# Eval("ID") %>' OnClientClick="verificalogincomprarartigo" ><img src="imagens/Shopcart-Add_48.png" alt="" align="middle" border="0" /></asp:LinkButton> <script type="text/javascript"> function verificalogincomprarartigo() { $(document).ready(function () { $("#info").hide(); $("#LinkButton1").click(function () { $("#info").show().animate({ margin: 0 }, 4000).fadeOut(); }); }); return false //prevent the ASP.NET button from causing a postback in firefox http://bytes.com/topic/asp-net/answers/880146-javascript-function-linkbutton-not-firing-firefox-browser } </script>however i forget that i have to check if a user is logged and and this messages just shows if a user is logged in i have a session var for that iduser (code behind) i have to serach a litle more to find how to do this
RaviSM
Contributor
2622 Points
589 Posts
Re: linkbutton javascript
Mar 01, 2011 01:53 AM|LINK
lb.Attributes.Add ("onclick","javascript:return verificalogincomprarartigo()"); you can see in rendred html it is rendered that onClientclick event is rendred as onclick() event onlyCustom watermark on PDF
Thanks and Regards
Ravi Mathpal
hsl89
Member
476 Points
441 Posts
Re: linkbutton javascript
Mar 01, 2011 07:06 AM|LINK
but i cant solve like this:
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="addToCart" CommandArgument='<%# Eval("ID") %>' OnClientClick="verificalogincomprarartigo" ><img src="imagens/Shopcart-Add_48.png" alt="" align="middle" border="0" /></asp:LinkButton> <script type="text/javascript"> function verificalogincomprarartigo() { $(document).ready(function () { $("#info").hide(); $("#LinkButton1").click(function () { $("#info").show().animate({ margin: 0 }, 4000).fadeOut(); }); }); return false //prevent the ASP.NET button from causing a postback in firefox http://bytes.com/topic/asp-net/answers/880146-javascript-function-linkbutton-not-firing-firefox-browser } </script>however i need to run only this function if a user is not logged in so i need a rsponse.write before this to check if user is logged in or not.
why you insist in lb.atributtes.add if i have a onclientclick property?
and how can i run a function here before this script to check if user is logged in
i have a ssesion var in condebihind on this button also in CommandName="addToCart" but i cant use this var Userid here since i'm not in codebind right?
RaviSM
Contributor
2622 Points
589 Posts
Re: linkbutton javascript
Mar 01, 2011 07:16 AM|LINK
If you use this you can check for session also you can add it conditonally if(Session["UserID"]!=null) { lb.Attributes.Add ("onclick","javascript:return verificalogincomprarartigo()"); }Custom watermark on PDF
Thanks and Regards
Ravi Mathpal
hsl89
Member
476 Points
441 Posts
Re: linkbutton javascript
Mar 01, 2011 08:05 AM|LINK
ok so way to do it in source only .
but the function verificalogincompraartigo stills on souce right?
RaviSM
Contributor
2622 Points
589 Posts
Re: linkbutton javascript
Mar 01, 2011 08:13 AM|LINK
lb.Attributes.Add ("onclick","javascript:return verificalogincomprarartigo()");
As you are adding this particular line if the Session is not null
if(Session["UserID"]==null)
lb.Attributes.Add("onclick","return false;");
Custom watermark on PDF
Thanks and Regards
Ravi Mathpal