2013-08-02 3 views
0

첫 번째 이미지를 확인하십시오. enter image description here링크 버튼을 클릭 한 후 페이지를 다시로드해야합니다.

이 페이지에서는 LinkButton을 사용합니다. 이제 (처럼 ... "sr001", "sr003"모든)

.aspx 페이지

<asp:LinkButton ID="lnkbtn" runat="server" onclick="lnkbtn_Click" 
ValidationGroup='<%# Eval("pid") %>'><%#Eval("productcode") %></asp:LinkButton> 

.cs 페이지

protected void lnkbtn_Click(object sender, EventArgs e) 
{ 
    int id; 
    id = Convert.ToInt32(((LinkButton)sender).ValidationGroup.ToString()); 
    string abc = "http://development.in/prod-more-info.aspx?pid=" + id; 
    Response.Write("<script>window.open('" + abc.ToString() + "','_blank');</script>"); 
} 

, I가 CLIK 이 링크 버튼 프로세스가 성공적으로 작동합니다.

하지만 ..............

내 디자인은 2 차 이미지를 보면,이 프로세스에 의해 방해된다 ..

enter image description here

이 문제를 어떻게 해결할 수 있습니까? 말 그대로 그냥 응답 스트림에 컨텐츠를 추가하기 때문에 원시을 Response.Write를하는

제발 도와주세요 ....

답변

2

은 바람직하지 않습니다.

스크립트가 올바른 위치에 나타나고 실행되도록하려면 ClientScriptManager.RegisterStartupScript을 대신 사용해야합니다.

ClientScriptManager cs = Page.ClientScript; 

if (!cs.IsStartupScriptRegistered(this.GetType(), "MoreInfoPopup")) 
{ 
    int id; 
    id = Convert.ToInt32(((LinkButton)sender).ValidationGroup.ToString()); 
    string abc = "http://development.in/prod-more-info.aspx?pid=" + id; 
    string script = String.Format("<script>window.open('{0}','_blank');</script>",abc); 
    cs.RegisterStartupScript(this.GetType(), "MoreInfoPopup", script); 
} 
+0

감사합니다 조쉬, 작동합니다. :) –

+0

@RajanVachhani - 문제 없음 :) – Josh

+0

안녕하세요 저는 로컬에서이 기능을 시도했지만 정상적으로 작동하지만 서버에서 온라인 상태 일 때 작동하지 않습니다 .. –

0

버튼을 클릭하면 페이지를 새로 고침 하시겠습니까? 그렇다면 response redirect ~ Request.Url.AbsolutePath으로하십시오.

코드 :

Response.Redirect(System.Web.HttpContext.Current.Request.Url.AbsolutePath);

+0

나는 이것을 시도했으나 Response.Write (""코드를 사용하여 작동하지 않는다. –

관련 문제