2009-03-11 2 views
0

나는 소스가 볼 때이처럼 보이는 ASP.NET의 DDL 있습니다ASP.NET 2.0 : AutoPostBack은과의 onChange에서 자바 스크립트 함수를 호출 = 사실

<select name="testControl" onchange="DoCustomStuff();setTimeout('__doPostBack(\'testControl\',\'\')', 0)" id="testControl"> 

그것은 .cs 페이지에 다음과 같습니다를 :

<asp:DropDownList ID="testControl" runat="server" onchange="DoCustomStuff()" OnSelectedIndexChanged="testControl_Changed" AutoPostBack="true" /> 

사람이 같은 DDL에 onchange를하고 AutoPostBack을 = "true"를 사용하여 문제를 볼 수 있을까요? DoCustomStuff()가 제대로 호출되지 않는 사용자가 있기 때문에 DoCustomStuff()가 작업을 완료하기 전에 __doPostBack()이 실행될 수 있는지 궁금합니다.

답변

0

봅니다처럼 수동으로 다시 게시 참조를 연결하려면 :

Page.ClientScript.RegisterClientScriptBlock(
    typeof(_Default), 
    "PageScripts", 
    string.Format("function DoCustomStuff() { /* Your Code Here */ {0} }", Page.ClientScript.GetPostBackEventReference(testControl, string.Empty)) 
); 

testControl.Attributes["onchange"] = "DoCustomStuff();"; 

이 당신에게 다시 게시 클라이언트 측 기준 제공 :

Page.ClientScript.GetPostBackEventReference(testControl, string.Empty)) 
관련 문제