Merging Java and VB for alert box

J

Jeff

I am new to VB.net 2005 in visual web developer, and even newer to
Javascript.

I need a java alert box that contains text that eventually will come from an
sql table.
The alert box should activate when the user clicks on text or a button (or
something similar).
The test code below will do most of what I need (I didn't include the code
to retrive from the table for simplicity).
Since I don't know much java, I'm attempting to do as much of this as easily
as possible in an aspx.vb codebehind file rather than attempting to figure
out how to directly embed the java on the page.

The only problem is that I don't want the Button to post back, and asp
button postbacks can't seem to be disabled.
What is the easy alternative? An HTML button apparently requires me to use
code with which I'm not yet familiar to alter the alter text. Is there some
other way to do what I want?


Dim a As String = "testing popup"
Dim code As New StringBuilder
code.Append("alert('")
code.Append(a)
code.Append("')")
BtnInfo.OnClientClick = (code.ToString)

Thanks in advance

Jeff
 
R

RobinS

You might want to post this to microsoft.public.dotnet.framework.aspnet.

Robin S.
 
C

Cor Ligthert [MVP]

Jeff,

I have a sample from a html textbox that you can use.

However do it in a VB.Net way.

Just open a textbox on your page that you hide when you don't need it.
Than a nice label below in the same way and your user will be much hapier
than with such an ugly dialogbox.

Cor
 
J

Jeff

Cor Ligthert said:
Jeff,

I have a sample from a html textbox that you can use.

However do it in a VB.Net way.

Just open a textbox on your page that you hide when you don't need it.
Than a nice label below in the same way and your user will be much hapier
than with such an ugly dialogbox.

Cor

I thought of that and was trying that previously. The problem is that many
of my users will be students working on an 800x600 monitor and there is a
space issue with the other items on the page. If I put in the textbox, I had
to toggle something else invisible to make things fit.

I did more checking and found out that by adding the "return false" to the
alert box code, that the postback could be disabled. Apparently the return
false typically was designed for confirmation boxes, but it works for alert
boxes also. So the below does what I want, although I wish there were a more
elegant solution,
similar to opening the texbox as you mentioned. I may keep messing with the
cosmetics and
figure out a better way.

Dim code As New StringBuilder
code.Append("alert('")
code.Append(QuestionTableCopy.Item(0)("QuestionMore"))
code.Append("');return false")
BtnInfo.OnClientClick = (code.ToString)
 
C

Cor Ligthert [MVP]

But in ASP you can use VB.Net as well.
This is not direct an installation or whatever question, it is in my idea
about using the VB.net language.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top