bullrout
asked on
how can I disable the form button after it has been clicked? - Novice Question
Hi There,
I am wondering how I can disable the form button after it has been clicked, currently I am using the "onclick" event for the actual function I need to insert records. Has anyone got any good ideas about where I can place the function call?
Sean
onClick="Insertlisting_Cli ck"
onclick="disableform()"
function disableform()
{
document.forms[0].SubmitBu ttton.disa bled = true;
document.forms[0].SubmitBu ttton.valu e = 'Please wait...';
document.forms[0].submit() ;
}
I am wondering how I can disable the form button after it has been clicked, currently I am using the "onclick" event for the actual function I need to insert records. Has anyone got any good ideas about where I can place the function call?
Sean
onClick="Insertlisting_Cli
onclick="disableform()"
function disableform()
{
document.forms[0].SubmitBu
document.forms[0].SubmitBu
document.forms[0].submit()
}
ASKER
Hi There,
I'm not too sure where I have to place the code, do I just add it into the button control itself like below?
Sean
<asp:button id="btnSubmit" text="place listing" onClick="Insertlisting_Cli ck" SubmitButton.Attributes.Ad d "onclick", "disableform()") runat="server" EnableViewState="False" />
I'm not too sure where I have to place the code, do I just add it into the button control itself like below?
Sean
<asp:button id="btnSubmit" text="place listing" onClick="Insertlisting_Cli
nope, sorry that i've not been so clear
you have to place this code in the Page_load event
Regards,
B..M
you have to place this code in the Page_load event
Regards,
B..M
ASKER
ok so if I have a code behind with a page_load event, how can I call this ?
sean
sean
using the
SubmitButton.Attributes.Ad d("onclick ", "disableform()")
the .net framework will assing the client event for this button and when you press the button it will try to call disableform function on the client
you have to assign the page_load event to the page ( this is done autmatically except if you write the definition by hand
Regards,
B..M
SubmitButton.Attributes.Ad
the .net framework will assing the client event for this button and when you press the button it will try to call disableform function on the client
you have to assign the page_load event to the page ( this is done autmatically except if you write the definition by hand
Regards,
B..M
Hi,
try this
in the .cs file(the code behind file)
private void Page_Load(object sender, System.EventArgs e)
{
btnSubmit.Attributes.Add(" OnClick"," javascript :disablefo rm();");
}
in the aspx file write this
<HTML>
<HEAD>
<title>MyTitle</title>
<script language="javascript">
function disableform()
{
document.forms[0].SubmitBu ttton.disa bled = true;
document.forms[0].SubmitBu ttton.valu e = 'Please wait...';
document.forms[0].submit() ;
}
</script>
</HEAD>
if you still have problem with this technique then have a look at this article
http://www.codeproject.com/aspnet/ClickOnce_Button_Control.asp
Regards,
venki
try this
in the .cs file(the code behind file)
private void Page_Load(object sender, System.EventArgs e)
{
btnSubmit.Attributes.Add("
}
in the aspx file write this
<HTML>
<HEAD>
<title>MyTitle</title>
<script language="javascript">
function disableform()
{
document.forms[0].SubmitBu
document.forms[0].SubmitBu
document.forms[0].submit()
}
</script>
</HEAD>
if you still have problem with this technique then have a look at this article
http://www.codeproject.com/aspnet/ClickOnce_Button_Control.asp
Regards,
venki
ASKER
Hi Venki,
The function seems to overide the validation I have on the page, do I need to call the required field validator that I have on the page inside this javascript fucntion?
Sean
The function seems to overide the validation I have on the page, do I need to call the required field validator that I have on the page inside this javascript fucntion?
Sean
Hi,
I don't thinkk it will override the validation, I think the validation fires first, then the onClick I am not sure in this I need to check that.
Regards,
venki
I don't thinkk it will override the validation, I think the validation fires first, then the onClick I am not sure in this I need to check that.
Regards,
venki
Put this in the page load and you can re-enable whenever you need.
If page.ispostback Then
Mybutton.visibile = false
End If
Regards,
Aeros
If page.ispostback Then
Mybutton.visibile = false
End If
Regards,
Aeros
ASKER
I will try this and let you guys know the outcome.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And don't forget to check this link to try the demo and download the code.
http://aspzone.com/archive/2004/01/06/292.aspx
http://aspzone.com/archive/2004/01/06/292.aspx
you have to do it by javascript, not in the code behind
to that you have to use
SubmitButton.Attributes.Ad
Regards,
B..M