Click here to Skip to main content
15,885,856 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
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
Updated 18-Nov-12 18:31pm
v2
Comments
Sergey Alexandrovich Kryukov 19-Nov-12 0:01am    
Tag it: ASP.NET.
--SA

use
location.href="/KB/answers/delete.aspx"?id=" + ID
 
Share this answer
 
Comments
melvintcs 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
I solved it

JavaScript
function del(ID)
{
   if(confirm('delete?')){
   window.open('delete.aspx?ID=' + ID);
}
else
{
   return false;
}

HTML
<a  önclick="javascript:del(<%# Eval('comp_id') %>);"> delete </a>
 
Share this answer
 
v4

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900