ASP.NET : 프로그래밍 방식으로 윈도우에서 서버 측 이벤트를 발송합니다. 자바 스크립트가있는 Pener

StackOverflow https://stackoverflow.com/questions/5043866

문제

onSelectedIndExchanged 이벤트에서 일부 서버 측 데이터를 불러 오는 DropDownList가 있습니다.

<asp:DropDownList ID="ddlGroup" runat="server" 
     AutoPostBack="True" OnSelectedIndexChanged="SelectGroup" />
.

다른 곳에서는 일부 JavaScript가 팝업을 엽니 다.팝업이 채워지고 제출되면 JavaScript를 사용하여 Opener 페이지에서 OnSelectedIndexChanged 이벤트를 화면하고 싶습니다.나는 비슷한 것을하는 다른 코드를 발견했다 :

    if (window.opener != null ) {
    var cf = window.opener.document.forms['aspnetForm'];
        if (!cf) {
            cf =  window.opener.document.aspnetForm;
        }
        cf.__EVENTTARGET.value = "prAdded";
        cf.__EVENTARGUMENT.value = "winClosed";
        cf.submit(); 
    }
.

나는 이것이 내가 찾고있는 것이라고 생각하지만, eventTarget과 eventargument 부분에 무엇이 필요한지, 또는 내가 필요로하는 경우에도 무엇이 필요한지 모르겠다.OnSelectedIndexChangedddlGroup 이벤트 핸들러를 특별히 실행하고 싶습니다.이게 / 실용적인가?

2 차 질문 : POPUP에서 서버 측 코드를 실행 한 후 상위 페이지를 새로 고치는가?

도움이 되었습니까?

해결책

Eh, you could do it that way, but I'd just use __doPostback() instead. That sets __EVENTTARGET and __EVENTARGUMENT to the two parameters, and assuming your first parameter is the UniqueID of an UpdatePanel, causes just that UpdatePanel to refresh.

So either you can set things up so refreshing the updatepanel does what you want to happen, or you can check those values on postback -- Request.Form["__EVENTTARGET"] ... and go from there.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top