First of all, thanks for your response, Cor.
I have been wrestling with this for a while, looking at some interesting
posts via Google, and I have succeeded in getting the desired value into a
javascript variable thus:
In the html:
<input type="hidden" name="HiddenUserName" id="HiddenUserName" />
In the vb routine
Sub GetUsername()
Dim ret as String 'This is the value I want to capture
Dim msg As String = "Type your name"
Dim sKey As String = "sKey"
Dim alertScript As String = "<script language=JavaScript> var ret,
HiddenUID; ret = prompt('" & msg & "'); var HiddenUID =
document.getElementbyId('HiddenUserName'); HiddenUID = ret; <" & "/script>"
RegisterClientScriptBlock(sKey, alertScript)
End Sub
The value for ret is trapped in the RegisterClientScriptBlock call, but I
don't know how to get it into the vb side (server-side). I get an error
saying 'document.getElementbyId is not a supported.
Can anyone tell me how to pass the value for ret from the client to the
server? I would need a pretty explicit answer.
Thanks,
David
"Dave" <da*****************************@stic.net> wrote in message
news:ul**************@tk2msftngp13.phx.gbl...
I have a vb routine below where I'm trying to capture a name from a
javascript prompt box. My application is inline VB on Visual Studio 2003.
The prompt box does display, but when I type a string and hit OK or
Cancel, the value 'ret' which I want to hold the value of the string, is always
empty. And the status bar always says "Done but with errors on page."
If I use a simpler control like alert or confirm, I get no problems.
Can someone point out my error, either conceptual, syntactical, or
whatever?
Thanks,
Dave
Sub GetUsername()
Dim ret as String 'This is the value I want to capture
Dim msg As String = "Type your name"
Dim sKey As String = "sKey"
Dim alertScript As String = "<script language=JavaScript runat=server>
'" & ret & "' = prompt('" & msg & "'); <" & "/script>"
RegisterClientScriptBlock(sKey, alertScript)
End Sub