c#中的javascript确认问题 [英] javascript confirmation problem in c#
本文介绍了c#中的javascript确认问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
i在asp.net网页上有一个确认弹出窗口。
实际上我的页面上有一个下面的弹出窗口。
但它是一个VB.NET客户端代码。
然后它在我身边工作正常。
但不幸的是它在C#中没有用。
也许我已经放置了相同的代码,我从VB.NET输出了它。
所以我的问题是为什么它不适用于c#?
请找到下面的代码,
hi all,
i have a confirmation popup window in asp.net web page.
Actually i have a below to popup window on my page.
but it was a VB.NET client side code.
and then it was working fine my side.
but unfortunately it has not been works in C#.
and perhaps i have placed same code which i have made it output from VB.NET.
So my problem is why it is not working in c#?
please find the code below,
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function DeleteCli(id)
{
// window.open("JHProducts.asp?ID=" + id );
return confirm("Are you sure you want to delete this number?"+ id,null,"status=yes,resizable=no,left=350,top=250,width=350,height=250");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="LinkButton1" runat="server" BorderColor="White" OnClientClick ='<%# String.Format("javascript: return DeleteCli(""{0}"");", Eval("CLI"))%>' BorderStyle="none" CausesValidation="false" CommandArgument='<%# Eval("CLI") %>' CommandName="delete" Text ="Delete"/>
</div>
</form>
</body>
</html>
提前感谢..
thanks in advance..
推荐答案
没有VB.NET客户端代码这样的东西。您在VB.NET(或C#)中编写的任何代码都在服务器上运行。
根据您发布的内容,您只需需要在OnClientClick
属性中转换服务器端String.Format
调用。
您有两种选择:
1。使用C#文字字符串前缀为字符串@
:
There is no such thing as "VB.NET client-side code". Any code you write in VB.NET (or C#) runs on the server.
Based on what you've posted, you just need to convert the server-sideString.Format
call in yourOnClientClick
attribute.
You have two options:
1. Use a C# literal string by prefixing the string with@
:
OnClientClick='<%# String.Format(@"javascript: return DeleteCli(""{0}"");", Eval("CLI"))%>'
2。转义字符串中的嵌入式引号:
2. Escape the embedded quotes within the string:
OnClientClick='<%# String.Format("javascript: return DeleteCli(\"{0}\");", Eval("CLI"))%>'
这篇关于c#中的javascript确认问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文