473,320 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using Client-Side scripting

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

Nov 21 '05 #1
5 1153
Dave,

You write in your JavaScript "Runat Server" what will not work with an
alert.

As well has the alert no messagebox part, it is only an "Alert".

Standard is for what you want to use a loginform or otherwise a normal
textbox.

I thought that I had seen that using VBScript somebody could use a kind of
DHTML "messagebox". However I don't remember me anymore where, maybe you can
look for yourself on Google or MSDE for this. I am myself not interested in
that and keep it to the more standard way of doing this.

However maybe somebody knows that DHTML "messagebox" method.

I hope this gives any ideas anyhow.

Cor
Nov 21 '05 #2
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

Nov 21 '05 #3
Dave,

As I wrote had seen this as well, however did not know anymore where.

As far as I remember me, (it is a while ago I did that) is a simple way to
transport data from client to serverer is using a hidden textbox where you
place (using JavaScript) the information in.

Maybe I try your messagebox, however don't promish that

I hope this helps anyway.

Cor
Nov 21 '05 #4
Dave,

I think that in this way it can work, however there should be better
methods.

\\\ a textbox and a button on a form
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim str As String
If Not IsPostBack Then
TextBox1.ForeColor = Color.White
TextBox1.BorderStyle = BorderStyle.None
Dim alertScript As String = _
"<script language=JavaScript>document.all.item('TextBox1'). value
" & _
" = prompt('Give me text','My name is nobody'); </script>"
RegisterStartupScript("Startup", alertScript)
Else
str = TextBox1.Text
End If
End Sub
///
I hope this helps a little bit?

Cor
Nov 21 '05 #5
Cor, thanks very much. I need to buff this up a little, but I think it
will work. That document.all.item was they key for me.

David
"Cor Ligthert" <no************@planet.nl> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
Dave,

I think that in this way it can work, however there should be better
methods.

\\\ a textbox and a button on a form
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim str As String
If Not IsPostBack Then
TextBox1.ForeColor = Color.White
TextBox1.BorderStyle = BorderStyle.None
Dim alertScript As String = _
"<script language=JavaScript>document.all.item('TextBox1'). value " & _
" = prompt('Give me text','My name is nobody'); </script>"
RegisterStartupScript("Startup", alertScript)
Else
str = TextBox1.Text
End If
End Sub
///
I hope this helps a little bit?

Cor

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Frank | last post by:
Hi, is there a way to use XSL to compare two XML files to verify if a "record" in an XML file has changed of parent in another XML file ? I am trying to implement a template in an XSL stylesheet...
6
by: roger beniot | last post by:
I have a program that launches multiple threads with a ThreadStart method like the following (using System.Net.Sockets.Socket for UDP packet transfers to a server): ThreadStart pseudo code: ...
2
by: Kumar | last post by:
Hi, I am trying to develop FTP client application using c#. Our application functinality should be like this: 1.our client uploads files,folders to our ftp server for every 20 minutes. ...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
0
by: Glich via DotNetMonster.com | last post by:
#using <mscorlib.dll> #using <System.dll> #include "stdlib.h" #include "stdio.h" using namespace System; using namespace System::Text; using namespace System::IO; using namespace...
3
by: Michael Hoehne | last post by:
Hi, I'm currently facing a problem with a mixed environment using .NET 1.1 and ..NET 2.0 web services. We have a client application (the "client", system 1) running on .NET 2.0/WinXP, calling...
0
by: mahesh anasuri | last post by:
Hi all, I am new to this mailing list. Thankful if any one is using curl/linux version to and worked on Https. I have created certificates (PEM format) for client and server using openSSL. I...
2
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: ...
14
by: ml_sauls | last post by:
I've built a system to enter and manage purchase orders. This is in use by >10 clients. Some use it in Access 97, most are in A2k. About half use it through a Citrix implementation. It is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.