Pular para o conteúdo principal

Botão de clique único

Single Button Click Custom Control
This article demonstrates a custom control for button which gets disabled after user clicks on it so that we can stop user to resubmit the same information again and again intentionally or unintentionally.
Here, when user clicks on submit button, its first checks the validation part. After passing it, the data gets posted & button gets disabled. After that the button gets enabled for new submission. Also the text written in the textbox gets changes dynamically.
For Custom Control, go to new project. Select Web Custom Control & rename it to singleClickBtn.
A custom control for button is developed. Here is the code snippet for it:-
public class singleClickBtn : Button
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
private string replaceTitleTo;
public string ReplaceTitleTo
{
get { return this.replaceTitleTo; }
set { this.replaceTitleTo = value; }
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
StringBuilder script = new StringBuilder();
script.Append("if (typeof(Page_ClientValidate) == 'function') { ");
script.Append("if (Page_ClientValidate() == false) { return false; }} ");
if (!String.IsNullOrEmpty(this.replaceTitleTo))
{
script.Append("this.value = '");
script.Append(this.replaceTitleTo);
script.Append("';");
}
script.Append("this.disabled = true;");
script.Append(this.Page.ClientScript.GetPostBackEventReference(this,String.Empty));
script.Append(";");
this.Attributes.Add("onclick", script.ToString());
}

In above code, I am inheriting Button class so that I can override its methods. After that a property is declared to overwrite the text written in Button. On initialization event of button, I am checking for Client Validate function. If it returns true the button gets disabled else it will remain intact.
Now our custom control is ready. Build it first in debug mode then in release mode. After that create a new website. Right click on the Toolbox. Click on choose item and add the dll of the custom control we just developed. Drag and drop it on any aspx page. Now, it is just like other webcontrols fully customizable.
Drop a textbox. Place validation on it & check.
Link:
http://www.codedigest.com/Articles/ASPNET/234_Single_Button_Click_Custom_Control.aspx

Comentários

Postagens mais visitadas deste blog

EmguCV DLL Not Found Exception -Unable to find cvextern?

Eu também tive os mesmos problemas. Neste fórum emgucv , não sei por que cvextern.dlldo emgucv 3.4.3 não é possível carregar cvextern (porque não é possível encontrar cvextern), e você permitiu usar o arquivo cvextern.dlldo emgucv 3.4.2 (certifique-se de escolher x64 / x86), copie /bin/Debuge este arquivo é encontrado automaticamente /bin/Debug/x86ou /bin/Debug/x64quando você termina de construir o programa no Visual Studio.  O Erro:  The type initializer for 'Emgu.CV.CvInvoke' threw an exception. : Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)  Para resolver o problema copia a pasta x64 ou x86 para dentro da pasta bin da aplicação. Ou copie os arquivos para dentro da pasta bin da aplicação WCF.

Vagas .Net - Projeto CNSA

Prezados, Estamos selecionando candidados, em forma de cadastro de reserva, para participar do projeto: Cadastro Nacional de Sociedade de Advogados, na Assessoria de Tecnologia da Informação do Conselho Federal da OAB. Basicamente teremos 3 fases: * Avaliação Curricular; * Entrevista Pessoal; * Verificação prática; Outras informações: Vaga: Desenvolvedor .NET. Quantidade: 3. Tempo: 4 meses. Segue abaixo os requisitos que devem ser atendidos pelo candidato: Conhecimentos básicos * Conhecimento avançado em C#; * Conhecimento em ASP.NET 2.0; * ADO.NET 2.0; * SQL SERVER 2005 (DML, stored procedures, MER); * UML (Interpretação de casos de uso, diagrama de atividades, de classe, de sequência); * Experiência em projetos anteriores com ASP.NET e C#; Desejável * LINQ TO SQL; * Conhecimento em JavaScript e padrões Web (XHTML, CSS, etc); * ASP.NET 3.5; * C# 3.0 (LINQ, Propriedade implementadas automaticamente, Métodos de Extensão, Expressão Lamb...

Lista de IPs DNS Oi nos Estados

As vezes quando colocamos um IP fixo para uma máquina na rede, e esta rede tem acesso a internet através da rede da Oi, bem provável que você não conseguirá acessar a internet. Para resolver o problema defina o DNS primário e Secundário nas propriedades da placa de rede. - Protocolo TCP/IP Versão 4 (TCP/IPv4). Segue lista de DNS por estado. RS 201.10.1.2 201.10.120.3 SC 201.10.120.3 201.10.1.2 PR 201.10.120.2 201.10.128.3 GO 201.10.128.3 201.10.120.3 DF 201.10.128.2 201.10.120.2 MS 201.10.128.3 201.10.1.2 MT 201.10.128.2 201.10.120.3 RO/AC 201.10.128.2 201.10.1.2