B
bay_dar
Hi, I have an internal ASP.NET application that I'm are using to send
e-mails out based on a single milepost or milepost range entered.
I'm trying to do two things when a user clicks on the submit button
to submit a form that contains one or two Mileposts:
1) If a Milepost range larger than 5 miles is entered, I would
like to
pop up a confirmation box to confirm the range.
2) If the user hit's OK to the confirmation box, or there was only
1
milepost entered, or the range is less than 5 miles, I would like the
button click event to process the sending of the email AND disable the
button. Otherwise they may submit the form several times.
The way the code is listed below, the button will get disabled, but the
button..Click function never gets executed. If I remove the
this.disabled=true; statement from the statement below, the button does
not get disabled, but the button..click event does run through. Any
idea if I can get this to work?
Here is the behind .VB code located in the Page_Load event -
btn_email_event.Attributes.Add("onclick", "javascript:
this.disabled=true; return mpRangeOK();" &
GetPostBackEventReference(btn_email_event).ToString)
Then I have the email function:
Private Sub btn_email_event_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_email_event.Click
....
Here is the Javascript function I have in the .aspx page
function mpRangeOK()
{
//This function will be called when a user clicks on
the button to
submit an email and it
//will pop up a confirmation box IF two MP's were
entered AND IF
their difference is
//greater than 5.
//The function returns false if they want to modify
their range
//It will return nothing (UNDEFINED) otherwise
(allowing the VB
button_click code to run.)
//NOTE - THE VB button_click will have additional
validation as well
//THIS is called from the email-publish.aspx.vb
btn_email_event.Attributes.Add("onclick"... Event
var mpstart, mpend, mpdiff;
mpstart = document.Form1.textboxMPStart.value;
mpend = document.Form1.textboxMPEnd.value;
//document.Form1.btn_email_event.disabled=true;
//IF BOTH mp's fields were entered and they are
both numeric values
if ((mpend.length > 0) && (!isNaN(mpend)) &&
(mpstart.length > 0) &&
(!isNaN(mpstart)) )
{
//Get absolute value of the difference
- we have to round it up,
convert it to
//an integer, and then reconvert to an
integer - otherwise would
get a values like .0000100005
mpdiff = (Math.round(Math.abs(mpstart -
mpend)* 100))/100;
if (mpdiff > 5)
{
if (!confirm(" Are you sure
you want this event to cover a range
of " + mpdiff + " MILES?" +
"\n\nYou entered a starting
Milepost " +
"of " + mpstart + " and an " +
"ending Milepost of " + mpend +
".\n\n
Hit OK to ACCEPT this range" +
".\n\n Hit
CANCEL to MODIFY this range."))
{
document.Form1.btn_email_event.disabled=false;
return false;
}
}
}
}
Thanks
e-mails out based on a single milepost or milepost range entered.
I'm trying to do two things when a user clicks on the submit button
to submit a form that contains one or two Mileposts:
1) If a Milepost range larger than 5 miles is entered, I would
like to
pop up a confirmation box to confirm the range.
2) If the user hit's OK to the confirmation box, or there was only
1
milepost entered, or the range is less than 5 miles, I would like the
button click event to process the sending of the email AND disable the
button. Otherwise they may submit the form several times.
The way the code is listed below, the button will get disabled, but the
button..Click function never gets executed. If I remove the
this.disabled=true; statement from the statement below, the button does
not get disabled, but the button..click event does run through. Any
idea if I can get this to work?
Here is the behind .VB code located in the Page_Load event -
btn_email_event.Attributes.Add("onclick", "javascript:
this.disabled=true; return mpRangeOK();" &
GetPostBackEventReference(btn_email_event).ToString)
Then I have the email function:
Private Sub btn_email_event_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_email_event.Click
....
Here is the Javascript function I have in the .aspx page
function mpRangeOK()
{
//This function will be called when a user clicks on
the button to
submit an email and it
//will pop up a confirmation box IF two MP's were
entered AND IF
their difference is
//greater than 5.
//The function returns false if they want to modify
their range
//It will return nothing (UNDEFINED) otherwise
(allowing the VB
button_click code to run.)
//NOTE - THE VB button_click will have additional
validation as well
//THIS is called from the email-publish.aspx.vb
btn_email_event.Attributes.Add("onclick"... Event
var mpstart, mpend, mpdiff;
mpstart = document.Form1.textboxMPStart.value;
mpend = document.Form1.textboxMPEnd.value;
//document.Form1.btn_email_event.disabled=true;
//IF BOTH mp's fields were entered and they are
both numeric values
if ((mpend.length > 0) && (!isNaN(mpend)) &&
(mpstart.length > 0) &&
(!isNaN(mpstart)) )
{
//Get absolute value of the difference
- we have to round it up,
convert it to
//an integer, and then reconvert to an
integer - otherwise would
get a values like .0000100005
mpdiff = (Math.round(Math.abs(mpstart -
mpend)* 100))/100;
if (mpdiff > 5)
{
if (!confirm(" Are you sure
you want this event to cover a range
of " + mpdiff + " MILES?" +
"\n\nYou entered a starting
Milepost " +
"of " + mpstart + " and an " +
"ending Milepost of " + mpend +
".\n\n
Hit OK to ACCEPT this range" +
".\n\n Hit
CANCEL to MODIFY this range."))
{
document.Form1.btn_email_event.disabled=false;
return false;
}
}
}
}
Thanks