Groups | Blog | Home
all groups > dotnet jscript > april 2006 >

dotnet jscript : OnClientClick prevents OnClick from work


Bishoy George
4/9/2006 4:44:53 PM
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...

--


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

topgene
4/12/2006 3:12:11 AM
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
4/13/2006 1:30:37 PM
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



[quoted text, click to view]

nchineme NO[at]SPAM parkwayprojects.com
5/8/2006 1:21:30 AM
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

AddThis Social Bookmark Button