.net 目标为空的服务器代码

.net 目标为空的服务器代码,.net,hyperlink,.net,Hyperlink,应用程序是.Net。我想记录在超链接上的点击。很简单。我将其更改为链接按钮,现在可以执行所需的服务器端代码来记录单击。问题是:现在我无法启动指向空白目标的链接。我想吃我的蛋糕,也想吃。服务器端代码和一个空目标。怎么做?您可以使用: 例如: //定义页面上客户端脚本的名称和类型。 字符串csname1=“popuscript”; 类型cstype=this.GetType(); //从Page类获取ClientScriptManager引用。 ClientScriptManager cs=Page

应用程序是.Net。我想记录在超链接上的点击。很简单。我将其更改为链接按钮,现在可以执行所需的服务器端代码来记录单击。问题是:现在我无法启动指向空白目标的链接。我想吃我的蛋糕,也想吃。服务器端代码和一个空目标。怎么做?

您可以使用:

例如:

//定义页面上客户端脚本的名称和类型。
字符串csname1=“popuscript”;
类型cstype=this.GetType();
//从Page类获取ClientScriptManager引用。
ClientScriptManager cs=Page.ClientScript;
StringBuilder cstext1=新的StringBuilder();
cstext1.Append(“window.open(url,_blank')”;
RegisterStartupScript(cstype,csname1,cstext1.ToString());

勾选此项,然后回答。受保护的void LinkButton1\u单击(对象发送方,事件参数e){//记录单击的现有代码……//……//……//生成客户端代码以在新窗口中打开链接///(假设您已将URL存储在字符串变量//名为targetURL)ClientScript.RegisterStartupScript(this.GetType(),“openLinkInNewWindow”,“window.open(“+targetURL+”,“\u blank”);”,true);最后一个参数对我有效。谢谢!“发布代码”的意思是“编辑你的问题并在那里发布代码”,而不是“在评论中发布代码”。
// 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());