Click here to Skip to main content
11,639,178 members (63,707 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET
i put a hyperlink under my gridview.
<asp:TemplateField HeaderText="regular">
<asp:HyperLink ID="hlReset" runat="server" NavigateUrl='<%# deleteConfirm(Eval("comp_id")) %>'
Text='Delete'> </asp:hyperLink>
Code Behind:
public string deleteConfirm(object comp_id)
   string ID = (string)comp_id;
   return @"javascript:var result = confirm('Are you sure you want to delete selected item?');
      window.location='delete.aspx?id=' + ID;
      return false;

the popup message do appear, but it wont bring me to the new page after i click "Yes", i bet there is a problem with my javascript at code behind, please advice me.
Posted 18-Nov-12 16:20pm
Edited 18-Nov-12 18:31pm
Sergey Alexandrovich Kryukov at 19-Nov-12 0:01am
Tag it: ASP.NET.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

location.href="delete.aspx?id=" + ID
melvintcs at 19-Nov-12 1:11am
thx for the reply, i already tried that method, problem still remain, is there anyway i can rewrite the code by remove the "return" in front of the '@"javascript' ? please advice
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

I solved it

function del(ID)
   if(confirm('delete?')){'delete.aspx?ID=' + ID);
   return false;
<a  önclick="javascript:del(<%# Eval('comp_id') %>);"> delete </a>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Suvendu Shekhar Giri 280
1 Sergey Alexandrovich Kryukov 279
2 Richard Deeming 200
3 CPallini 187
4 PIEBALDconsult 175
0 OriginalGriff 9,081
1 Sergey Alexandrovich Kryukov 8,812
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,600
4 F-ES Sitecore 2,548

Advertise | Privacy | Mobile
Web03 | 2.8.150728.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100