Click to See Complete Forum and Search --> : Dynamic Alert/MessageBox
RobDog888
Mar 28th, 2006, 04:43 AM
Run this code from any code behind event to invoke a alert/msgbox without having to use Page.RegisterStartupScript() or using an objects .Attributes property to tie an js alert to it.
This is independant from any object and just like having a VB6/VB.NET Messagebox.
Protected Sub SomeSub(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write("<script language=javascript>alert('This is a dynamic alert.');</script>") '
End Sub
mendhak
Mar 28th, 2006, 08:24 AM
Edit
Dude, not a good idea.
Response.Write is not a good thing to use on ASP.NET pages.
RobDog888
Mar 28th, 2006, 08:48 AM
Then how would you recomend invoking a alert without having to use a hidden control or something?
Say if you wanted to evaluate a couple of aspx controls and depending on the scenerio, call a message?
Fishcake
Nov 9th, 2006, 07:07 PM
Then how would you recomend invoking a alert without having to use a hidden control or something?
Say if you wanted to evaluate a couple of aspx controls and depending on the scenerio, call a message?
By using Page.RegisterStartupScript.
RobDog888
Nov 12th, 2006, 03:00 PM
Yes, I learned that one a while ago as it was a question froggy couldnt answer when I was just starting to learn asp.net. :D
freefall
Nov 15th, 2006, 10:15 PM
Edit
Dude, not a good idea.
Response.Write is not a good thing to use on ASP.NET pages.
then what else do u use to display anything on the page from the code-behind?
RobDog888
Nov 15th, 2006, 11:05 PM
Hes means to use other methods like - Me.Page.RegisterStartupScript(...
or ...
Me.Page.RegisterClientScriptBlock(...
freefall
Nov 15th, 2006, 11:27 PM
ahh ok, so for registering javascripts...
not exactly just trying to display Hello, World! on the page..
Cool, thanks for clearing that up
RobDog888
Nov 15th, 2006, 11:36 PM
Me.Page.RegisterStartupScript("script1", "<script language='JavaScript' type='text/javascript'>alert('Hello World');</script>")No need for js in the html. :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.