1

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

2 Answers 2

1

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)
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.