Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
i put a hyperlink under my gridview.
 
<asp:TemplateField HeaderText="regular">
 
<ItemTemplate>
 
<asp:HyperLink ID="hlReset" runat="server" NavigateUrl='<%# deleteConfirm(Eval("comp_id")) %>'
Text='Delete'> </asp:hyperLink>
 
</asp:TemplateField>
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?');
 
   if(result)
 
   {
 
      window.location='delete.aspx?id=' + ID;
 
   }
 
   else{
 
      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
v2
Comments
Sergey Alexandrovich Kryukov at 19-Nov-12 0:01am
   
Tag it: ASP.NET.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I solved it
 
function del(ID)
{
   if(confirm('delete?')){
   window.open('delete.aspx?ID=' + ID);
}
else
{
   return false;
}
<a  önclick="javascript:del(<%# Eval('comp_id') %>);"> delete </a>
  Permalink  
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

use
location.href="delete.aspx?id=" + ID
  Permalink  
Comments
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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 499
1 Nirav Prabtani 338
2 OriginalGriff 175
3 _Amy 165
4 Abhinav S 160
0 OriginalGriff 7,715
1 Sergey Alexandrovich Kryukov 6,911
2 Maciej Los 3,954
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2014
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