Solved

Is it possible to disable an ImageButton when processing?

Posted on 2013-12-19
7
187 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
Comment Utility
Ok, don't worry try this

document.getElementByID(imgbtn).disabled = true;

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

Expert Comment

by:Mrunal
Comment Utility
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
Comment Utility
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
Comment Utility
Found solution by myself.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now