Reputation: 1454
I am using the code below to generate a popup box. Where is says "The information is ready to be submitted" I would like to add "Your reference number is 12345" I am getting that reference number using a session i.e. Session("ID"). Is there a way I can add this to the string?
Try
Dim msg As String = "Hello!"
Dim script As String = "if(confirm('The information is ready to be submitted')) {window.location.href ='frmMain.aspx'; }"
ScriptManager.RegisterClientScriptBlock(Me, Me.[GetType](), "Test", script, True)
Catch ex As Exception
End Try
Upvotes: 1
Views: 260
Reputation: 34834
Try this:
Try
Dim msg As String = "Hello!"
Dim idValue As String = CType(Session("ID"), String)
Dim script As String = "if(confirm('The information is ready to be submitted. Your reference number is " & idValue & "')) {window.location.href ='frmMain.aspx'; }"
ScriptManager.RegisterClientScriptBlock(Me, Me.[GetType](), "Test", script, True)
Catch ex As Exception
End Try
Upvotes: 1
Reputation: 44971
Yep. Just add the information to your script string (I switched the string to stringbuilder for slight efficiency gain):
Dim sbScript As New System.Text.StringBuilder(200)
sbScript.Append("if(confirm('The information is ready to be submitted. Your reference number is ").Append(Session("ID"))
sbScript.Append("')) {window.location.href ='frmMain.aspx'; }")
ScriptManager.RegisterClientScriptBlock(Me, Me.[GetType](), "Test", sbScript.ToString(), True)
Upvotes: 1