.net 20 callback example

code behind
    #region ICallbackEventHandler 成员
    protected string CallBackValue = string.Empty;

    string  ICallbackEventHandler.GetCallbackResult()
    {
        return  ValidateQuestion(CallBackValue).ToString();
    }
    void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
    {
        this.CallBackValue = eventArgument;
    }
    #endregion

 private string  ValidateQuestion(string txtinputData)
    { 
    return "somthing error";
}


html:

function CallServer()
            {
                var txtinput=  document.all("txtinputdata").value;
                <%=ClientScript.GetCallbackEventReference(this,"txtinput","ReceiveServerData",null) %>;
            }
            function ReceiveServerData(rValue)
            {
                if(rValue.indexOf("False")!=-1)
                {
                    validatetxt= rValue.substr(6);
                    validateAnswerType=1;
                 }
            }

你可能感兴趣的:(callback)