I'm trying to pass a GUID variable via the query string. When I run my game, I can see the needed variable in the querystring when it hits the page(planetID):
http://ec2.us-east-2.compute.amazonaws.com/World_Generation/GeneratePlanet.aspx?planetID=3b757g83-f211-1236-a52c-226fw9a9f9d5
However, when I try to display that variable, I get this error in my browser console window(Chrome):
Uncaught ReferenceError: planetID is not defined
Here is my code. You can see that I am declaring the variable 'planetID' and setting it from the query string value:
Partial Public Class PlanetGallery
Page.Header.DataBind()
Public planetID As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not String.IsNullOrEmpty(Request.QueryString("planetID")) Then planetID = Request.QueryString("planetID")
ScriptManager.RegisterStartupScript(Page, Me.Page.GetType, "test", "alert('planetID from PlanetGallery_PageLoad Sub' + planetID);", True)
End Sub
End Class
I'm not sure why it's not working. I think I need another pair of eyes.
If anyone has any suggestions, I'd love to hear them!
Thanks!
planetID. You're not passing the value of yourplanetIDVB variable, you're literally passing the string"planetID"to JavaScript."alert('planetID from PlanetGallery_PageLoad Sub" & planetID & "');"- If you want the actual value of your variable to get passed, it can't be within quotes. The javascript that you're actually passing in your example is:alert('planetID from PlanetGallery_PageLoad Sub' + planetID);- By passing the word planetID instead of its value, the JavaScript thinks it's a variable.