?
Solved

write to response stream *after* response.redirect? (redirect PLUS modal dialog)

Posted on 2006-05-11
3
Medium Priority
?
494 Views
Last Modified: 2008-02-01
Hello-

I'm trying to redirect a response AND popup a dialog explaining why.

Here's the code I've been using to popup messages, but I am not having any luck putting it before or after the Response.Redirect:

  System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
  System.Web.HttpContext.Current.Response.Write("alert(""" & MessageHere & """)" & vbCrLf)
  System.Web.HttpContext.Current.Response.Write("</SCRIPT>")

Any help greatly appreciated-

VB.NET 1.1
0
Comment
Question by:ottenm
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
the_paab earned 800 total points
ID: 16660654
Response.Redirect is performed on the server thus you must decide if you want to display message before last postback on original page or on load event in new page. You can do e.g. this:

Original page:
       Session("redirecting") = True
       Response.Redirect("default4.aspx")

New page:
       If not Page.IsPostBack Then
         If Session("redirecting") = True then
            System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
            System.Web.HttpContext.Current.Response.Write("alert(""" & MessageHere & """)" & vbCrLf)
            System.Web.HttpContext.Current.Response.Write("<")
            System.Web.HttpContext.Current.Response.Write("/")
            System.Web.HttpContext.Current.Response.Write("SCRIPT>")
         End If
        End If
0
 
LVL 6

Expert Comment

by:the_paab
ID: 16660815
Another solution. Insead of response.redirect on original page use this code:

            Dim scriptString As String = "<script language=JavaScript>alert('message'); window.location='secondpage.aspx';"
            scriptString += "<"
            scriptString += "/"
            scriptString += "script>"
            If (Not IsClientScriptBlockRegistered("clientScript")) Then
                RegisterClientScriptBlock("clientScript", scriptString)
            End If
0
 

Author Comment

by:ottenm
ID: 16661114
Thanks the_paab!  

I just put the message string in the session, check for it on load, then display it and set it back to nothing.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question