2012-11-09 6 views
0

응용 프로그램은 .Net입니다. 하이퍼 링크 클릭 수를 기록하고 싶습니다. 충분히 쉬워. 링크 버튼으로 변경하여 클릭을 기록하는 데 필요한 서버 측 코드를 실행할 수 있습니다. 문제는 : 이제 _blank 대상에 대한 링크를 시작할 수 없습니다. 나는 내 케이크를 먹고 싶다. 서버 측 코드와 _blank 대상. 어떻게?_blank 대상 서버 코드

+1

당신이 코드를하시기 바랍니다 게시 할 수 있습니까? –

+0

이 답변을 확인하십시오. http://stackoverflow.com/questions/2637087/link-button-property-to-open-in-new-tab – ryadavilli

+0

보호 된 무효 LinkButton1_Click (개체 발신자, EventArgs e) { // 클릭 ... // ... // ... // 새 창에서 링크를 여는 클라이언트 측 코드 생성 // (이것은 문자열 변수에 URL을 저장했다고 가정합니다. // 명명 된 targetURL) ClientScript.RegisterStartupScript (this.GetType(), "openLinkInNewWindow", "window.open ('"+ targetURL + "', '_blank');"); –

답변

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());