Thursday, 28 May 2015

Disable ASP.NET Button after click | Disable Double Click


About UseSubmitBehavior:

     Use the UseSubmitBehavior property to specify whether a Button control uses the client browser's submit mechanism or the ASP.NET postback mechanism. By default the value of this property is true, causing the Button control to use the browser's submit mechanism. If you specify false, the ASP.NET page framework adds client-side script to the page to post the form to the server.

OnClientClick:

Use the OnClientClick property to specify additional client-side script that executes when a Button control's Click event is raised. The script that you specify for this property is rendered in the Button control's OnClick attribute in addition to the control's predefined client-side script.


Source:

<asp:Button ID="btnSubmit" runat="server" Text="Submit" UseSubmitBehavior="false"
     OnClientClick="this.disabled='true';this.value='Please Wait...'"

        OnClick="btnSubmit_Click" />



Code Behind:

protected void btnSubmit_Click(object sender, EventArgs e)
    {
Thread.Sleep(9000); // Wait for 9 Seconds
    }


Output:


Tuesday, 28 April 2015

Show Binary Image in ASP.NET without using handler | Bind Binary Image in ASP.NET

Here we are going to bind the binary image from database.
Our binary image in in the varbnary(max) formatted in the database.

We Need to Add HTML Image control in design view:
<img runat="server" id="ProfileImage" />

And in code behind we have to add this:
First bind the Dataset and write below this code
byte[] imageBytes=Convert.ToBase64String((byte[])'DataSet Image Field');//replace DataSet Image field with varbinary Field.
ProfileImage.Src = "data:image/png;base64,"imageBytes;


You are done all the steps. The image will be display.