简体   繁体   English

从后端 c# 代码单击 hfref 打开一个弹出窗口

[英]Open a popup window on a hfref click from Backend c# code

I am trying to open a popup window from backend c# code on an ahref.我正在尝试从 ahref 上的后端 c# 代码打开一个弹出窗口。 打开弹出窗口

As you can see, this is done on a datatable row如您所见,这是在数据表行上完成的

    foreach(LinkCustomerFile lcf in linkedCustomerFiles)
    {
     var readLinkType = ecfsc.GetLinkType(lcf.LinkType.LinkTypeId,DateTime.Now,Page.User.Identity.Name);
           dt.Rows.Add("7","45",readLinkType,string.Format("<a href='../LinkCustomerFiles.aspx?action={0}&customerFileId={1}&referenceNumber={2}&linkcustId={3}' target='popup'>{0} </a>  ","Remove",lcf.CustomerFile.CustomerFileId,lcf.RefCustomerFile.CustomerFileId,lcf.LinkCustomerFileId));
   }
    RadGridLink.DataSource=dt;
    RadGridLink.DataBind();

Is there a way to achieve the popup window from this code when ever user click Remove当用户单击“删除”时,有没有办法从此代码实现弹出窗口

Just a minor addition in your code.只是在您的代码中添加了一小部分。

1st) Just add the JavaScript code on OnClick attribute of a tag directly. 1)直接在标签的 OnClick 属性上添加 JavaScript 代码即可。

@foreach(LinkCustomerFile lcf in linkedCustomerFiles)
            {
            var readLinkType = ecfsc.GetLinkType(lcf.LinkType.LinkTypeId,DateTime.Now,Page.User.Identity.Name);
            dt.Rows.Add("7","45",readLinkType,string.Format("<a href='../LinkCustomerFiles.aspx?action={0}&customerFileId={1}&referenceNumber={2}&linkcustId={3}' target='popup' onclick='return confirm('Are you sure you want to Logout?')'>{0} </a>  ","Remove",lcf.CustomerFile.CustomerFileId,lcf.RefCustomerFile.CustomerFileId,lcf.LinkCustomerFileId));
            }
            RadGridLink.DataSource=dt;
            RadGridLink.DataBind();

2nd) Another way is to add the Javascript code: 2)另一种方法是添加 Javascript 代码:

<script>
function myFunction() {
   return confirm('Are you sure you want to Logout?')
}
</script>

Then call the function in your code directly:然后直接调用代码中的函数:

@foreach(LinkCustomerFile lcf in linkedCustomerFiles)
            {
            var readLinkType = ecfsc.GetLinkType(lcf.LinkType.LinkTypeId,DateTime.Now,Page.User.Identity.Name);
            dt.Rows.Add("7","45",readLinkType,string.Format("<a href='../LinkCustomerFiles.aspx?action={0}&customerFileId={1}&referenceNumber={2}&linkcustId={3}' target='popup' onclick='myFunction()'>{0} </a>  ","Remove",lcf.CustomerFile.CustomerFileId,lcf.RefCustomerFile.CustomerFileId,lcf.LinkCustomerFileId));
            }
            RadGridLink.DataSource=dt;
            RadGridLink.DataBind();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM