Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Can you force client-side processing on a Web Form Button Control?


Message #1 by "Linda Hunnicutt" <lhunni@s...> on Tue, 14 Aug 2001 20:52:26
  Has anyone found a way to force a Web Form Button Control to process on 

the client, then either 1)continue on to the server or 2) cancel server 

processing?  (This would be similar functionality to 

the "onbeforeserverevent" in the "old" Design Time Controls in InterDev.)

  Thanks.
Message #2 by "Jeremy Stephenson" <jeremy@a...> on Fri, 17 Aug 2001 22:59:08
You could, for example, force the web form to do some client side 

processing first, like so:



<form id="myform" method="post" runat="server" onsubmit="return 

validateForm(this);">



and some JavaScript:



function validateForm(objForm){

if (someTestCondition){

	alert("Something went wrogn");

	return false;

}

else	{

	return true;

}

}



if the return value is false, the page post will be cancelled.  probably.



Cheers







>   Has anyone found a way to force a Web Form Button Control to process 

on 

> the client, then either 1)continue on to the server or 2) cancel server 

> processing?  (This would be similar functionality to 

> the "onbeforeserverevent" in the "old" Design Time Controls in InterDev.)

>   Thanks.
Message #3 by "Linda H" <lhunni@s...> on Thu, 23 Aug 2001 18:49:40
That works at the form level, but has anyone found a way to force a Web 

Form BUTTON control to process on the client before it goes to the 

server?  When I insert this control within a form:



  <asp:Button id=btnTest runat="server" onclick="return Foo this);">       

</asp:Button>



I get the following error message:



   Compiler Error Message: BC30456: The name 'return' is not a member 

of 'ASP.WebForm1_aspx'.





> You could, for example, force the web form to do some client side 

> processing first, like so:

> 

> <form id="myform" method="post" runat="server" onsubmit="return 

> validateForm(this);">

> 

> and some JavaScript:

> 

> function validateForm(objForm){

> if (someTestCondition){

> 	alert("Something went wrogn");

> 	return false;

> }

> else	{

> 	return true;

> }

> }

> 

> if the return value is false, the page post will be cancelled.  probably.

> 

> Cheers

> 

> 

> 

> >   Has anyone found a way to force a Web Form Button Control to process 

> on 

> > the client, then either 1)continue on to the server or 2) cancel 

server 

> > processing?  (This would be similar functionality to 

> > the "onbeforeserverevent" in the "old" Design Time Controls in 

InterDev.)

> >   Thanks.
Message #4 by Ankur Kalsi <akalsi@q...> on Thu, 23 Aug 2001 11:08:23 -0700
The following script should work:

Place the following code between the <HEAD> section:

	<script for=3DbtnTest event=3Donclick>

		if (someTestCondition)

		{

	 		alert("Something went wrong");

		 	return false;

		}

	</script>



Place this within a <FORM> control:

	<asp:Button id=3DbtnTest runat=3D"server" onclick=3D"DeleteRecord">

"DeleteRecord" can be a server side function.



AK



-----Original Message-----

From: Linda H [mailto:lhunni@s...]

Sent: Thursday, August 23, 2001 11:50 AM

To: ASP+

Subject: [aspx] Re: Can you force client-side processing on a Web Form

Button Control?





That works at the form level, but has anyone found a way to force a Web 



Form BUTTON control to process on the client before it goes to the

server?  When I insert this control within a form:



  <asp:Button id=3DbtnTest runat=3D"server" onclick=3D"return Foo 

this);">      

</asp:Button>



I get the following error message:



   Compiler Error Message: BC30456: The name 'return' is not a member

of 'ASP.WebForm1_aspx'.





> You could, for example, force the web form to do some client side

> processing first, like so:

>

> <form id=3D"myform" method=3D"post" runat=3D"server" 

onsubmit=3D"return

> validateForm(this);">

>

> and some JavaScript:

>

> function validateForm(objForm){

> if (someTestCondition){

> 	alert("Something went wrogn");

> 	return false;

> }

> else	{

> 	return true;

> }

> }

>

> if the return value is false, the page post will be cancelled.  

probably.

>

> Cheers

>

>

>

> >   Has anyone found a way to force a Web Form Button Control to 

process

> on

> > the client, then either 1)continue on to the server or 2) cancel

server

> > processing?  (This would be similar functionality to

> > the "onbeforeserverevent" in the "old" Design Time Controls in

InterDev.)

> >   Thanks.
Message #5 by "Jason Lung" <jason@e...> on Thu, 23 Aug 2001 15:17:33 -0400

How can i keep track of the Integer (i) in order to do my increment? Thx

in advance

----------------------------------------------------------------------



Public Class WebForm1

    Inherits System.Web.UI.Page

    Protected WithEvents lbl_Username As System.Web.UI.WebControls.Label

    Protected WithEvents lbl_Password As System.Web.UI.WebControls.Label

    Protected WithEvents txb_Username As

System.Web.UI.WebControls.TextBox

    Protected WithEvents txb_Password As

System.Web.UI.WebControls.TextBox

    Protected WithEvents btn_Reset As System.Web.UI.WebControls.Button

    Protected WithEvents lbl_ErrorMessage As

System.Web.UI.WebControls.Label

    Protected WithEvents lbl_Welcome As System.Web.UI.WebControls.Label

    Protected WithEvents btn_Submit As System.Web.UI.WebControls.Button



#Region " Web Form Designer Generated Code "



    'This call is required by the Web Form Designer.

    <System.Diagnostics.DebuggerStepThrough()> Private Sub

InitializeComponent()



    End Sub



    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Init

        'CODEGEN: This method call is required by the Web Form Designer

        'Do not modify it using the code editor.

        InitializeComponent()

    End Sub



#End Region



    Dim i As Integer



    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load

        If Not Page.IsPostBack Then

            lbl_ErrorMessage.Text =3D "Welcome to My Site !"

        End If

    End Sub



    Private Sub btn_Submit_Click(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles btn_Submit.Click

        i =3D i + 1

        lbl_ErrorMessage.Text =3D "Welcome back to My Login ! for " & i 

&

" times ?!"

    End Sub



    Private Sub btn_Reset_Click(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles btn_Reset.Click

        txb_Username.Text =3D ""

        txb_Password.Text =3D ""

    End Sub



End Class

Message #6 by Todd Carrico <ToddC@m...> on Thu, 23 Aug 2001 14:59:48 -0500
You need to keep it in the Session, either using session variable, or

sending it to the page in a hidden field.



Something along those lines.



tc





-----Original Message-----

From: Jason Lung [mailto:jason@e...] 

Sent: Thursday, August 23, 2001 2:18 PM

To: ASP+

Subject: [aspx] RE: Can you force client-side processing on a Web Form But

ton Control?





How can i keep track of the Integer (i) in order to do my increment? Thx

in advance

----------------------------------------------------------------------



Public Class WebForm1

    Inherits System.Web.UI.Page

    Protected WithEvents lbl_Username As System.Web.UI.WebControls.Label

    Protected WithEvents lbl_Password As System.Web.UI.WebControls.Label

    Protected WithEvents txb_Username As

System.Web.UI.WebControls.TextBox

    Protected WithEvents txb_Password As

System.Web.UI.WebControls.TextBox

    Protected WithEvents btn_Reset As System.Web.UI.WebControls.Button

    Protected WithEvents lbl_ErrorMessage As

System.Web.UI.WebControls.Label

    Protected WithEvents lbl_Welcome As System.Web.UI.WebControls.Label

    Protected WithEvents btn_Submit As System.Web.UI.WebControls.Button



#Region " Web Form Designer Generated Code "



    'This call is required by the Web Form Designer.

    <System.Diagnostics.DebuggerStepThrough()> Private Sub

InitializeComponent()



    End Sub



    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Init

        'CODEGEN: This method call is required by the Web Form Designer

        'Do not modify it using the code editor.

        InitializeComponent()

    End Sub



#End Region



    Dim i As Integer



    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load

        If Not Page.IsPostBack Then

            lbl_ErrorMessage.Text = "Welcome to My Site !"

        End If

    End Sub



    Private Sub btn_Submit_Click(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles btn_Submit.Click

        i = i + 1

        lbl_ErrorMessage.Text = "Welcome back to My Login ! for " & i &

" times ?!"

    End Sub



    Private Sub btn_Reset_Click(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles btn_Reset.Click

        txb_Username.Text = ""

        txb_Password.Text = ""

    End Sub



End Class

  Return to Index