If the client script depends on information that is available only at run time,you cannot add it declaratively at design time.For this situation, ASP.NET enables you to generate and render client side code at run time.To do this ,use the System.Web.UI.ClientScriptManager class.The following example adds a script that will execute in the browser when the user attempts to submit the form back to the Web Server.
VB
Sub page_Load( )
Dim scriptText As String
scriptText = "return Confirm('Do you want to submit the page? ')"
ClientScript.RegisterOnSubmitStatement(Me.GetType( ). _
ConfirmSubmit , scriptText)
End Sub
C#
void Page_Load( )
{
String scriptText = "return confirm('Do you want to submit the page?')" ;
ClientScript.RegisterOnSubmitStatement(this.GetType( ),ConfirmSubmit , scriptText ) ;
}
VB
Sub page_Load( )
Dim scriptText As String
scriptText = "return Confirm('Do you want to submit the page? ')"
ClientScript.RegisterOnSubmitStatement(Me.GetType( ). _
ConfirmSubmit , scriptText)
End Sub
C#
void Page_Load( )
{
String scriptText = "return confirm('Do you want to submit the page?')" ;
ClientScript.RegisterOnSubmitStatement(this.GetType( ),ConfirmSubmit , scriptText ) ;
}
No comments:
Post a Comment