How to get the url of my hyperlink field within a gridview in a javascript function -
this hyperlink code:
<asp:hyperlink id="unlinkedusers" clientidmode="static" runat="server" onclick ="getsecurity();" navigateurl='<%# string.format("linkusers.aspx?user={0}&type={1}", eval("email"), eval("entitytype")) %>'text='link user'> and javascript code:
<asp:content id="contentplaceholderjs" contentplaceholderid="contentplaceholderjs" runat="server"> <script lang="javascript" type="text/javascript"> js
function getsecurity() { var linkurl = $(this).attr("href"); //alert(linkurl); $.ajax({ type: "post", url: "dashboard.aspx/checksecurity", contenttype: "application/json; charset=utf-8", //data: '{"username":"' + username + '"}', data: '{"objectname":"linkusers"}', //data: '{"objectname":"' + objectname + '"}', datatype: "json", success: function (data) { if (data.d == false) alert("you not have rights object."); else window.location.href = linkurl.tostring(); } }); } this not working. line:
var linkurl = $(this).attr("href"); on browser getting error:
typeerror: a.attributes undefined
...e.csstext}f&&a.setattribute(b,""+d);if(!a.attributes[b]&&a.hasattribute&&!a.hasa...
try using:
this.getattribute('href')
Comments
Post a Comment