Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / May 2006

Tip: Looking for answers? Try searching our database.

OnClientClick prevents OnClick from work

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bishoy George - 09 Apr 2006 15:44 GMT
Hi,
I have a server side form button with id btnsubmit
As the form is big, the submission process is slow.
A user may click on the button many times, I want to prevent that by
client-side code.

I made this function:

<script language="javascript" type="text/javascript">
function Disable()
{
   document.getElementById("btnSubmit").disabled = true;
}
</script>

then in the button server html I added  OnClientClick=""

<asp:Button ID="btnSubmit" runat="server" CssClass="Body"
OnClick="btnSubmit_Click"
                                           Text="Save And Continue!"
OnClientClick="Disable();" />

But the result was that the button is disabled once I click it and doesn't
make its server side code duties.

Any Help Please...

Signature

Bishoy George
bishoy@bishoy.com
bishoy.george@nagyresearch.com
0102550399

topgene - 12 Apr 2006 11:12 GMT
1/u can change the click event to doubleclick event;    ----
client-side
2/u can set the buttom enable = false in the onclick event;
---server-side
Bishoy George - 13 Apr 2006 12:30 GMT
May be my question was not clear.

I do want the both server and client actions to occur with button click.

The problem is:
When the server side action is alone it occurs.
After I add the OnClientClick attribute, client side action occurs but
server side action stops working.

Bishoy George
bishoy@bishoy.com
0102550399

> 1/u can change the click event to doubleclick event;    ----
> client-side
> 2/u can set the buttom enable = false in the onclick event;
> ---server-side
Chineme Nnamdi - 08 May 2006 09:21 GMT
Hi Bishoy,

When you disable an asp button with client script it prevent the server side on click event from firing. What you need to do is to fire the onclick event of the button first before disabling the button. (view snippet below)

<script language="javascript" type="text/javascript">
function Disable()

        <%=Page.GetPostBackEventReference(btnSubmit as Control)%>
        document.getElementById('<%=btnSubmit.ClientID%>').disabled = true;
}
</script>

Chineme Nnamdi

Technology Development Group
Parkway Projects Limited
7 Olumo street,
Onike, Yaba,
Lagos

Mobile 1:  234 803 9212860
Mobile 2:  234 1 8911807
Office:     234 1 4754362
Email:       nchineme@parkwayprojects.com
Website:  www.parkwayprojects.com

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.