Connecting Tech Pros Worldwide Forums | Help | Site Map

Help: ASP.NET - Message Display

Member
 
Join Date: Sep 2007
Posts: 71
#1: Sep 4 '08
Hi

Can i use message box to display message in webpage? Because i have used label and in the text property of the label i have written the javascript for displaying message in alert box.

It is working properly but after that i have redirected the page to another webpage, so the label having alert message is not being displayed to me and the page is redirected.

Help me whether i can use message box for it or not?

Thanks in advance...

Shashi Sadasivan's Avatar
Moderator
 
Join Date: Aug 2007
Location: Brisbane, Australia
Posts: 1,414
#2: Sep 4 '08

re: Help: ASP.NET - Message Display


Alert boxes can be used, and will behave in a modal manner.
i think you may need to put the redirect logic after the alert javascript.
I am not sure if having the alert message box, (as javascript ofcourse) and the redirect login as asp .net will work together as expected.
Member
 
Join Date: Sep 2007
Posts: 71
#3: Sep 4 '08

re: Help: ASP.NET - Message Display


Hi

I have placed the javascript codings above the code which redirects to another page only. But Javascript codings and redirecting page are working properly except that the page is redirected but i am not getting the alert box message but its codings are executed successfully.

Help me....
Member
 
Join Date: Sep 2007
Posts: 71
#4: Sep 5 '08

re: Help: ASP.NET - Message Display


Hi

Please help me...
Shashi Sadasivan's Avatar
Moderator
 
Join Date: Aug 2007
Location: Brisbane, Australia
Posts: 1,414
#5: Sep 6 '08

re: Help: ASP.NET - Message Display


Can you post your javascript code here?

Can you reproduce the same if you create a sample application?
Member
 
Join Date: Sep 2007
Posts: 71
#6: Sep 6 '08

re: Help: ASP.NET - Message Display


Hi

This is my code.

dim label1 as label
label1=new label
label1.text="<script language='javascript'>" & Environment.Newline & "window.alert("Your details has been updated successfully") </script>"
response.redirect("Home.aspx")

This code works properly for me, except that the alert message is not displayed to me and the page is redirected to homepage.

If i delete the response.redirect("Home.aspx"),alert message is displayed to me.

But i want both the codings to be worked.

Please help me.
Shashi Sadasivan's Avatar
Moderator
 
Join Date: Aug 2007
Location: Brisbane, Australia
Posts: 1,414
#7: Sep 6 '08

re: Help: ASP.NET - Message Display


That is exactly what is going wrong.
You need to register the script (and not set is as the text)
try searching for "RegisterStartupScript"
and "RegisterClientScriptBlock"

I think On every page load you would need to set the script up so that the script is already there at the client.

Currently (if i assume that that piece of code is from the button event handler) the so called script text that you are setting will have no effect. (it is considered as text. and hence has no effect
Reply