|
-
Jan 21st, 2008, 05:57 AM
#1
Thread Starter
Hyperactive Member
OnClientCLick problem
Hi,
I have a Button control when clicked fires some javascript which sets a DIV tag visibility to true. This all works fine, but what it doean't do is fire the serverside OnClick button event?
My Javascript code:
Code:
<script type="text/javascript">
function showSending(e)
{
linkID = document.getElementById(e)
linkID.disabled = true;
linkID = document.getElementById("sending")
linkID.style.visibility = "visible";
}
</script>
My HTML Code:
Code:
<form id="form1" runat="server">
<div>
<asp:Button ID="btnSending" runat="server" Text="Sending" OnClientClick="return showSending(this.id)" OnClick="btnSending_Click" />
<div id="sending" style="border: solid 1px green; padding: 5px; width:55px; font-family:Verdana; font-size:12px; visibility:hidden;">Sending..</div>
</div>
</form>
My OnClick event:
Code:
protected void btnSending_Click(object sender, EventArgs e)
{
// Do some stuff here
}
So once the div tag visibility is set i then want the button event to fire?
-
Jan 21st, 2008, 06:55 AM
#2
Re: OnClientCLick problem
try changing
OnClientClick="return showSending(this.id)"
to
OnClientClick="showSending(this.id)"
at a guess this is a file upload message so that should work.
-
Jan 21st, 2008, 08:40 AM
#3
Thread Starter
Hyperactive Member
Re: OnClientCLick problem
Unfortunately that doens't work. Once the button is clicked the onClick event still isn't being fired.
-
Jan 22nd, 2008, 05:05 PM
#4
Thread Starter
Hyperactive Member
Re: OnClientCLick problem
This is a message that should appear after a file is attached to an message then emailed.
I just need a message to appear after the button click. ANy idea's how to get the server side code to fire?
-
Jan 23rd, 2008, 02:04 PM
#5
Re: OnClientCLick problem
If the source of the submit is disabled, i.e. your button, the page won't submit. Simply delaying the disable for a tad may work:
Code:
function showSending(button) {
window.setTimeout("button.disabled = true", 50);
var linkID = document.getElementById("sending");
linkID.style.visibility = "visible";
return true;
}
</script>
<asp:Button ID="btnSending" runat="server" Text="Sending" OnClientClick="return showSending(this)" OnClick="btnSending_Click" />
<div id="sending" style="border: solid 1px green; padding: 5px; width:55px; font-family:Verdana; font-size:12px; visibility:hidden;">Sending..</div>
-
Jan 24th, 2008, 11:05 AM
#6
Thread Starter
Hyperactive Member
Re: OnClientCLick problem
I tried this but i get the following error:
'Microsoft JScript runtime error: 'button' is undefined'
-
Jan 24th, 2008, 02:41 PM
#7
Re: OnClientCLick problem
The OnClientClick property changed to "return showSending(this)"
-
Jan 25th, 2008, 12:13 PM
#8
Thread Starter
Hyperactive Member
Re: OnClientCLick problem
I couldn't get it working the way i wanted it to so i had to set the button visibility to hidden once it was clicked.
It does the same job which is preventing the user from clicking the button again so i'm not complaining.
Thanks.
-
Jan 25th, 2008, 01:04 PM
#9
Re: OnClientCLick problem
am I missing something or is showsending JS function not returning a value, which would make it return false always?
-
Jan 25th, 2008, 01:31 PM
#10
Re: OnClientCLick problem
 Originally Posted by kleinma
am I missing something or is showsending JS function not returning a value, which would make it return false always?
Originally, yes, but the version I posted was explicit in its return
-
Jan 25th, 2008, 01:38 PM
#11
Re: OnClientCLick problem
Didn't see your post there. At least we are on the same thought
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|