So I have a table that has a linkbutton at the top of each column header. The linkbutton sorts the table by using commandname="sort". When I click one of these buttons the page does a post back with the desired results. However, if I click on a link in the page that opens a jquery colorbox, instead of activating the javascript it redirects to a blank pages.
$(document).ready(function () {
$('.ManageImages').colorbox({ inline: true, innerwidth: 504, innerheight: 530, href: "#create-image-manager-dialog", escKey: false, overlayClose: false, onCleanup: function(){
postbackWithModal();
}});
});
...
...
...
<th><asp:LinkButton runat="server" CommandName="Sort" CommandArgument="ItemNumber" CssClass="table-link-sorter">SKU</asp:LinkButton></th>
...
...
...
<asp:LinkButton CssClass="ManageImages" ID="ManageImages" runat="server" OnClientClick="SetImageSKU(this);" Text="Image Management" PostBackUrl="#" />
If I click on the linkbutton with the postbackurl of #, it redirects me to a blank page instead of calling the jquery I have in the supplied javascript. Anyone know of a work around for this?
Try below code. If you only want to run javascript.
<asp:LinkButton Text="Image Management" runat="server" PostBackUrl="javascript:void(0)" OnClientClick="SetImageSKU(this);" CssClass="ManageImages" ID="ManageImages" CausesValidation="false"/>
that should do it. If you want to run javascript and code behind then change it to OnClientClick="return SetImageSKU(this);" and send true or false from SetImageSKU so when it will return true, Link button will cause postback.
hope it helps.