Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just asked a very similar question (which was answered): <a href="https://stackoverflow.com/questions/3527634/asp-net-custom-button-control-how-to-override-onclientclick-but-preserve-existi">ASP.NET Custom Button Control - How to Override OnClientClick But Preserve Existing Behaviour?</a></p> <p>Essentially you need to preserve the existing behaviour of the submit button (<code>__doPostBack</code>). You do this with <code>Page.GetPostBackEventReference(myButton)</code>.</p> <p>However with validation it's more difficult, so you'll need to do page validation inline (<code>Page.Validate()</code>) or create a custom control like i did and override the <code>OnClientClick</code> and <code>PostBackOptions</code> members.</p> <p>Custom control is better, as i can now just drop this control on any page i want this behaviour.</p> <p>You could do the same and expose a public property:</p> <pre><code>public string loadingText {get; set;} </code></pre> <p>Which could be used to customise the loading text on each page.</p> <p>You basically need to set the onclick attribute to do the following:</p> <pre><code>onclick = "if (Page_Validate()) this.text = 'Processing';{0} else return false;" </code></pre> <p>{0} should be the regular postback action, retrieved from Page.GetPostBackEventReference.</p> <p>The resulting logic will be: on click, validate the page, it it succeeds, change the text and postback, if it fails, return false - which will show the validation on the page.</p> <p>Have the button set to default text "Submit" in the HTML, then wrap the above logic in !Page.IsPostBack so it will reset the text on form submit.</p> <p>Hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload