带有_blank目标的服务器代码

时间:2012-11-09 15:00:10

标签: .net hyperlink

应用程序是.Net。我想记录超链接的点击次数。很容易。我将其更改为链接按钮,现在可以执行所需的服务器端代码来记录点击。问题是:现在我无法启动到_blank目标的链接。我想吃蛋糕也吃。服务器端代码和_blank目标。怎么办?

1 个答案:

答案 0 :(得分:0)

您可以使用:ClientScriptManager.RegisterStartupScript Method (Type, String, String)

例如:

// Define the name and type of the client scripts on the page.
String csname1 = "PopupScript";
Type cstype = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
StringBuilder cstext1 = new StringBuilder();
cstext1.Append("<script type=text/javascript>window.open(url, '_blank') </");
cstext1.Append("script>");
cs.RegisterStartupScript(cstype, csname1, cstext1.ToString());