.NET Framework Class Library
PageRegisterOnSubmitStatement Method

Note: This API is now obsolete.

Allows a page to access the client OnSubmit event. The script should be a function call to client code registered elsewhere.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)
Syntax
<[%$TOPIC/k4ceyfws_en-us_VS_110_1_0_0_0_0%]("The recommended alternative is ClientScript.RegisterOnSubmitStatement(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202")> _
Public Sub RegisterOnSubmitStatement ( _
	key As [%$TOPIC/k4ceyfws_en-us_VS_110_1_0_0_0_1%], _
	script As [%$TOPIC/k4ceyfws_en-us_VS_110_1_0_0_0_2%] _
)
[[%$TOPIC/k4ceyfws_en-us_VS_110_1_0_1_0_0%]("The recommended alternative is ClientScript.RegisterOnSubmitStatement(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202")]
public void RegisterOnSubmitStatement(
	[%$TOPIC/k4ceyfws_en-us_VS_110_1_0_1_0_1%] key,
	[%$TOPIC/k4ceyfws_en-us_VS_110_1_0_1_0_2%] script
)
[[%$TOPIC/k4ceyfws_en-us_VS_110_1_0_2_0_0%](L"The recommended alternative is ClientScript.RegisterOnSubmitStatement(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202")]
public:
void RegisterOnSubmitStatement(
	[%$TOPIC/k4ceyfws_en-us_VS_110_1_0_2_0_1%]^ key, 
	[%$TOPIC/k4ceyfws_en-us_VS_110_1_0_2_0_2%]^ script
)
[<[%$TOPIC/k4ceyfws_en-us_VS_110_1_0_3_0_0%]("The recommended alternative is ClientScript.RegisterOnSubmitStatement(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202")>]
member RegisterOnSubmitStatement : 
        key:[%$TOPIC/k4ceyfws_en-us_VS_110_1_0_3_0_1%] * 
        script:[%$TOPIC/k4ceyfws_en-us_VS_110_1_0_3_0_2%] -> unit

Parameters

key
Type: SystemString

Unique key that identifies a script block.

script
Type: SystemString

The client-side script to be sent to the client.

Remarks

The RegisterOnSubmitStatement method has been deprecated. Use the RegisterOnSubmitStatement method in the ClientScriptManager class.

Examples

The following code example demonstrates using the RegisterOnSubmitStatement to access a script that responds when a client-side Submit button is clicked. When this event occurs, the registered ECMAScript code is executed on the client.

Security noteSecurity Note

This example has a hidden field, which is a potential security threat. By default, you should validate the value of a hidden field as you would the value of a text box. ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.


     Dim scriptString As String = "<script language=""JavaScript""> function doClick() {"
scriptString += "document.write('<h4>' + myForm.myHiddenField.value+ '</h4>');}<"
scriptString += "/" + "script>"

RegisterHiddenField("myHiddenField", "Welcome to Microsoft!")

RegisterOnSubmitStatement("submit", "document.write('<h4>Submit button clicked.</h4>')")

RegisterStartupScript("startup", scriptString)
void Page_Load(Object sender, EventArgs e) 
{ 
   String scriptString = "<script language=\"JavaScript\"> function doClick() {";
   scriptString += "document.write('<h4>' + myForm.myHiddenField.value+ '</h4>');}<";
   scriptString += "/" + "script>";

   RegisterHiddenField("myHiddenField", "Welcome to Microsoft!"); 

   RegisterOnSubmitStatement("submit", "document.write('<h4>Submit button clicked.</h4>')"); 

   RegisterStartupScript("startup", scriptString);
} 
Version Information

.NET Framework

Supported in: 1.1, 1.0
Obsolete (compiler warning) in 4.5.1
Obsolete (compiler warning) in 4.5
Obsolete (compiler warning) in 4
Obsolete (compiler warning) in 3.5
Obsolete (compiler warning) in 3.5 SP1
Obsolete (compiler warning) in 3.0
Obsolete (compiler warning) in 3.0 SP1
Obsolete (compiler warning) in 3.0 SP2
Obsolete (compiler warning) in 2.0
Obsolete (compiler warning) in 2.0 SP1
Obsolete (compiler warning) in 2.0 SP2
Platforms

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.