2009-03-11 23 views
0

私はソースを見るときこのようなASP.NET DDLを持っています:ASP.NET 2.0:AutoPostBack = trueのonChangeからjavascript関数を呼び出す

<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" /> 

誰でもonchangeとAutoPostBack =このようなDDLの "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)) 
関連する問題