window.location在代码后面的问题 [英] problem with window.location at code behind
本文介绍了window.location在代码后面的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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;
}";
确实会出现弹出消息,但是单击是"后它不会带我进入新页面,我敢打赌后面的代码中的JavaScript出现问题,请告诉我.
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.
推荐答案
使用
location.href ="delete.aspx?id =" + ID
use
location.href="delete.aspx?id=" + ID
我已解决
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>
这篇关于window.location在代码后面的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文