I had used a webgrid and displayed the data fine.For one column in the webgrid i had used
grid.Column("SlmgReferenceNumber", header: "SLMG Number", format: @<text><label><a href="#" id="messages_slmgid" onclick="return MessagesViewClaim(this, '@item.NoteId', '@item.DealerId', '@item.SlmgReferenceNumber');">@item.SlmgReferenceNumber</a></label></text>),
i used ‘this’ as parameter in the function of onclick to get that particular anchor element but i cannot able to get it. It returns the url of the page. How to resolve it. I want the particular anchor element as the parameter in the onclick function.Can anyone please help me to find the solution..
No, you must have mistaken something. I suspect you have used an
alerton the first argument instead of usingconsole.log. Never usealertto debug your javascript code. It will show you things that are completely wrong.This doesn’t return the url of the page. It returns the anchor element that was clicked:
will show the id of the anchor. Unfortunately in your example you have given all your anchors the same id (
messages_slmgid) which obviously results into invalid HTML but once you fix that you should be OK.All this to say that apart from the id collision on your anchors your code works perfectly fine. You just didn’t use the proper tool to verify it. I’d recommend you FireBug in FireFox.