Thursday, 20 March 2014

How to use registeronsubmitstatement

It adds script that executes in response on page’s onsubmit event. It provides an opportunity of validation before accepting the user’s submission.

Method contains their as:

RegisterOnSubmitStatement(Type type,string key,string script)
 we can actually check if it is already been added somewhere else in our code,

IsOnSubmitStatementRegistered.This method will check if script with a given key and type pair is already registered on the page.

How to use It

ClientScriptManager csManager = Page.ClientScript;
        Type vartype = this.GetType();
        if (!csManager . IsOnSubmitStatementRegistered (vartype ,"buttonClick"))
        {
            StringBuilder messagetxt = new StringBuilder();
        messagetxt.Append(" ");
        csManager.RegisterOnSubmitStatement(vartype, "buttonClick" , messagetxt.ToString() );
        }

No comments:

Post a Comment