Solved

Is it possible to disable an ImageButton when processing?

Posted on 2013-12-19
7
196 Views
Last Modified: 2014-08-14
Is it possible to disable an ImageButton when processing?

I found a way to disable a Button when processing doing this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then

           Dim strProcessScript As String = "this.value='Processing...';this.disabled=true;"
           btnProcess.Attributes.Add("onclick", (strProcessScript + ClientScript.GetPostBackEventReference(btnProcess, "").ToString))

        End If
    End Sub

Open in new window

But I can't do the same for an ImageButton
0
Comment
Question by:miyahira
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 22

Expert Comment

by:Mrunal
ID: 39730964
Try same thing for image button, only change the following...


imagebtnidhere.Attributes.Add("onclick", (ClientScript.GetPostBackEventReference(btnProcess, "").ToString) + ";return false;")


This will result in even you click on image button, nothing will happen.

But remember to remove that "return false;" when processing is done.
0
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 39731637
hi.. you can disable button like this
Write this code in button clicked event. It is for disable button for some time.

Javascript :
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
function BeginRequestHandler(sender, args) {
document.getElementById('<%= lblMessage.ClientID %>').innerText = "Please Wait...";
document.getElementById('<%= btnSubmit.ClientID %>').innerText = "Please Wait";
args.get_postBackElement().disabled = true;
}
</script>

Code behind :

protected void btnSubmit_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(4000);
lblMessage.Text = "PostBack completed!!";
}

.aspx page
//And also you have to put script manager between form tag.

<asp:UpdatePanel ID="updpnlSubmit" runat="server">
<ContentTemplate>
<asp:Button ID="btnSubmit" Text="Submit" runat="server" OnClick="btnSubmit_Click" />
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
0
 
LVL 1

Author Comment

by:miyahira
ID: 39731710
Hi, mroonal. I tried your piece of code but it doesn't work. Imagebutton still keeps being enabled when processing.

Hi samirbhogayta, I can disable a Button control, but I can't do the same for an ImageButton.

It's quite strange that you can disable a Button control when processing, but it's not possible do it for ImageButton.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 39731757
Ok, don't worry try this

document.getElementByID(imgbtn).disabled = true;

document.getElementById(imgbtn).disabled = true;
0
 
LVL 22

Expert Comment

by:Mrunal
ID: 39738819
If still not working, then you can use simple UI blocker plug in.

like jQuery BlockUI

www.malsup.com/jquery/block/¿
0
 
LVL 1

Accepted Solution

by:
miyahira earned 0 total points
ID: 39804283
I found myself the solution:

" this.disabled=true; "  should come first.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then

           Dim strProcessScript As String = "this.disabled=true; this.value='Processing...';"
           btnProcess.Attributes.Add("onclick", (strProcessScript + ClientScript.GetPostBackEventReference(btnProcess, "").ToString))

        End If
    End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:miyahira
ID: 40260157
Found solution by myself.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question