hi there guys!
I have a scenario that is presently giving me sleepless nights. I need to call an asp method from an "onclick" html event but the method is being called too early.
Public Sub CheckForSomeErrors()
If Session("FliteDate") = "" Then
Response.Redirect("../Errorpage.aspx?ErrorDetails='Flight Date' cannot be blank!! Click 'Previous' to re-Enter value")
End If
If Session("ReturnDate") = "" Then
Response.Redirect("../Errorpage.aspx?ErrorDetails='Probable return Date' cannot be blank!! Click 'Previous' to re-Enter value")
End If
If Session("PreferedAirline") = "" Then
Response.Redirect("../Errorpage.aspx?ErrorDetails=Please indicate your preferred Airline! Click 'Previous' to re-Enter value")
End If
If Session("GsmNo") = "" Then
Response.Redirect("../Errorpage.aspx?ErrorDetails=Please your valid GSM No is of extreme importance! Click 'Previous' to re-Enter value")
End If
End Sub
this is the code in the asp form module we can call formx.
<table borderColor="green" height="150" cellSpacing="0" cellPadding="0" width="1020" border="0">
<tr>
<TD vAlign="top"><IMG id="navigationbuttons" height="150" alt="" src="../img/navigationbuttons.jpg" width="1005"
useMap="#m_navigationbuttons" border="0" name="navigationbuttons"><map id="m_navigationbuttons" name="m_navigationbuttons">
<area shape="RECT" alt="" coords="689,50,950,110" href="../default.aspx">
<area onclick="<%CheckForSomeErrors()%>" shape=RECT alt="" coords="364,40,654,110" href="prePassger2.aspx">
<AREA shape="RECT" alt="" coords="30,40,314,110" href="javascript:history.back();">
</map>
</TD>
</tr>
</table>
This is the html code calling the asp function from the onclick event of the html hyperlink.
So in effect the 'checkforsomeerrors' function should be called as the 'hotspot' or indicated area is clicked before the call to 'prePassger2.aspx' is evaluated. But in practice, the 'checkforsomeerrors' function is called each time formx is loaded which is not desirable. I had tried to trap which event is responsible for this (like 'onload' or 'onclick') but is yet to see it.
So in effect, if I am calling formx from formK, the 'checkforsomeerrors' function is called (that is the onclick event is fired) even before the formx is loaded giving undesirable results. The object is for the function to be called as the hyperlink to another page is clicked.
Please your ideas are welcome!!