Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to use javascript alert in asp.net with vb

Reply
Thread Tools

How to use javascript alert in asp.net with vb

 
 
MWulfe
Guest
Posts: n/a
 
      04-29-2010
I want to use javascript to do the equivalent to this Windows Form
code on an asp.net webpage using VB:

if x = 2 and y = 3 then
messagebox.show("This is a message")
end if

Many of the code I've found appears to be obsolete or includes lots of
other bells and whistles (adding an alert to a datagrid or a control
attribute), which I do not need and only find confusing. I'm using
Web Developer Express 2008.

Help would be appreciated! Thanks!
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      04-30-2010
On Apr 30, 1:56*am, MWulfe <mwu...@yahoo.com> wrote:
> I want to use javascript to do the equivalent to this Windows Form
> code on an asp.net webpage using VB:
>
> if x = 2 and y = 3 then
> * * * * messagebox.show("This is a message")
> end if
>
> Many of the code I've found appears to be obsolete or includes lots of
> other bells and whistles (adding an alert to a datagrid or a control
> attribute), which I do not need and only find confusing. *I'm using
> Web Developer Express 2008.
>
> Help would be appreciated! *Thanks!


if (x==2 && y==3)
alert("message");
 
Reply With Quote
 
 
 
 
Andy B.
Guest
Posts: n/a
 
      04-30-2010

"Alexey Smirnov" <> wrote in message
news:dee1feb1-764e-4470-90b1-...
On Apr 30, 1:56 am, MWulfe <mwu...@yahoo.com> wrote:
> I want to use javascript to do the equivalent to this Windows Form
> code on an asp.net webpage using VB:
>
> if x = 2 and y = 3 then
> messagebox.show("This is a message")
> end if
>
> Many of the code I've found appears to be obsolete or includes lots of
> other bells and whistles (adding an alert to a datagrid or a control
> attribute), which I do not need and only find confusing. I'm using
> Web Developer Express 2008.
>
> Help would be appreciated! Thanks!


if (x==2 && y==3)
alert("message");

How do you do that from the vb codebehind?


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      04-30-2010
"Andy B." <> wrote in message
news:#...

> How do you do that from the VB codebehind?


Probably something like:

If x = 2 And y = 3 Then
ClientScriptManager.RegisterStartupScript(Me.GetTy pe, "message",
"alert('This is a message');", True)
End If


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
qvo178 qvo178 is offline
Junior Member
Join Date: Aug 2008
Posts: 29
 
      04-30-2010
You can set it with registerclientscript
 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      04-30-2010
On Apr 30, 9:40*am, "Andy B." <a_bo...@sbcglobal.net> wrote:
> "Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message
>
> news:dee1feb1-764e-4470-90b1-...
> On Apr 30, 1:56 am, MWulfe <mwu...@yahoo.com> wrote:
>
> > I want to use javascript to do the equivalent to this Windows Form
> > code on an asp.net webpage using VB:

>
> > if x = 2 and y = 3 then
> > messagebox.show("This is a message")
> > end if

>
> > Many of the code I've found appears to be obsolete or includes lots of
> > other bells and whistles (adding an alert to a datagrid or a control
> > attribute), which I do not need and only find confusing. I'm using
> > Web Developer Express 2008.

>
> > Help would be appreciated! Thanks!

>
> if (x==2 && y==3)
> alert("message");
>
> How do you do that from the vb codebehind?


Sure, it's inline javascript. I think, he didn't mention that it must
be from the codebehind.

In addition to example by Mark, this can be done using public
variables as

vb.net
-----------------
Protected Dim x As Integer = 2
Protected Dim y As Integer = 3
-----------------

aspx
-----------------
if (<%=x%>==2 && <%=y%>==3)
alert("message");
-----------------

I think it should work as expected.
 
Reply With Quote
 
MWulfe
Guest
Posts: n/a
 
      05-05-2010
In fact I did end up using the in-line javascript and it works just fine.
The only minor drawbacks are that the screen goes blank on some systems but
only while the message is displayed, there is no flexibility is the dialog
title, the text in the message cannot really be formated, and there is
always a "beep" when the message is displayed. Still, it is a relatively
simple solution and it works consistently.

"Alexey Smirnov" <> wrote in message
news:8d028127-e652-4659-9f9f-...
On Apr 30, 9:40 am, "Andy B." <a_bo...@sbcglobal.net> wrote:
> "Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message
>
> news:dee1feb1-764e-4470-90b1-...
> On Apr 30, 1:56 am, MWulfe <mwu...@yahoo.com> wrote:
>
> > I want to use javascript to do the equivalent to this Windows Form
> > code on an asp.net webpage using VB:

>
> > if x = 2 and y = 3 then
> > messagebox.show("This is a message")
> > end if

>
> > Many of the code I've found appears to be obsolete or includes lots of
> > other bells and whistles (adding an alert to a datagrid or a control
> > attribute), which I do not need and only find confusing. I'm using
> > Web Developer Express 2008.

>
> > Help would be appreciated! Thanks!

>
> if (x==2 && y==3)
> alert("message");
>
> How do you do that from the vb codebehind?


Sure, it's inline javascript. I think, he didn't mention that it must
be from the codebehind.

In addition to example by Mark, this can be done using public
variables as

vb.net
-----------------
Protected Dim x As Integer = 2
Protected Dim y As Integer = 3
-----------------

aspx
-----------------
if (<%=x%>==2 && <%=y%>==3)
alert("message");
-----------------

I think it should work as expected.

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      05-05-2010
On May 5, 6:20*pm, "MWulfe" <mwu...@yahoo.com> wrote:
> In fact I did end up using the in-line javascript and it works just fine.
> The only minor drawbacks are that the screen goes blank on some systems but
> only while the message is displayed, there is no flexibility is the dialog
> title, the text in the message cannot really be formated, and there is
> always a "beep" when the message is displayed. *Still, it is a relatively
> simple solution and it works consistently.
>


You can think about using Web2.0/ASP.NET way by implementing
ModalPopupExtender. The ModalPopup extender allows to display a free
designed "popup" in a similar manner which prevents the user from
interacting with the rest of the page. The popup can be shown via
server in code behind and on the client in script. It can be designed
in any way and you can have any title and no beep would occurred. This
would not require any big changes in code, but in application
configuration (you would need to download and include
AjaxControlToolkit and setup it in the web.config file. More about
ModalPopupExtender and AjaxControlToolkit you can find here

http://www.asp.net/ajax/ajaxcontrolt...odalpopup.aspx

Cheers!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Alert..General Alert?..New Discovery?. =?Utf-8?B?U3BhbW1lcipLaWxsZXI=?= Wireless Networking 0 07-24-2007 03:36 PM
on click in popup window throws alert : need to avoid alert of postdata Ganesh ASP .Net 0 06-29-2007 06:51 AM
How to create a form Alert - Not using Alert Boxes Mersh Java 0 03-13-2007 04:14 PM
ALERT: Virus Scam Alert! Toronto Garage Door Company Computer Support 1 11-18-2003 04:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57