?
Solved

Is it possible to disable an ImageButton when processing?

Posted on 2013-12-19
7
Medium Priority
?
200 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Integration Management Part 2
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

839 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