Question

Je suis en train d'utiliser RadSpell de Telerik pour vérifier l'orthographe du texte lorsque l'utilisateur soumet.

La façon dont cela est censé fonctionner est en arrêtant le postback, ce qui déclenche la vérification orthographique par javascript, puis en cas spellcheckfinished manuellement à partir du réel postback. Le problème est que dans la dernière étape de l'événement ne se déclenche pas cliquée pour le bouton et le gestionnaire d'événements côté serveur ne fait jamais appelé.

Voici le code .aspx correspondant:

<script type="text/javascript" language="javascript">

    var spellCheckFinished = false;
    var btnClicked;

    function doSpellCheckStuff(btnTrigger) 
    {          
        btnClicked = btnTrigger;
        var spell = GetRadSpell('<%= rsMessage.ClientID %>');
     //   spell.add_clientCheckFinished(checkFinished);
        spell.startSpellCheck();
        return false;
    }

    function checkFinished(sender, args)
    {   
        args.SuppressCompleteMessage = true;
        setTimeout('MySubmit();', 100);
    }

    function MySubmit()
    {
        WebForm_DoPostBackWithOptions(
            new WebForm_PostBackOptions(btnClicked.id, '', true, '', '', false, true)
        );
    }
</script>

<tr>
            <td>
                <asp:Button ID="btnSubmit" OnClientClick="return doSpellCheckStuff(this);" Text="Submit" 
                            OnClick="btnSubmit_Click" runat="server" />
            </td>
            <telerik:RadSpell   ID="rsMessage" ControlToCheck="txtMessage" ButtonType="None" 
                                UseClassicDialogs="true" FragmentIgnoreOptions="All" 
                                OnClientCheckFinished="checkFinished" runat="server" />
        </tr>

Toute idée pourquoi btnSubmit_Click est pas appelé et comment je peux résoudre ce problème?

Était-ce utile?

La solution

Essayez d'injecter votre script postback comme:

string script = @"function MySubmit(){" +
                  this.Page.ClientScript.GetPostBackEventReference(myButton, string.Empty);
                  "}";

if (!this.Page.ClientScript.IsClientScriptBlockRegistered("myPostBackScript"))
{
    this.Page.ClientScript.RegisterClientScriptBlock(typeof(MyPage), "myPostBackScript", script, true);
}

Autres conseils

La dernière comme de doSpellCheckStuff () est toujours soit faux, qui arrête l'écouteur d'événement OnClick de courir.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top