Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with RegisterStartupScript

Posted on 2011-02-12
2
Medium Priority
?
481 Views
Last Modified: 2012-05-11
Hi Experts

I use this code on many forms with out any problems:

Dim csname1 As [String] = "PopupScript"
Dim cstype As Type = Me.[GetType]()
Dim cs As ClientScriptManager = Page.ClientScript

If Session("LOG") <> "OK" Then
            Session("LOG") = "ERROR"
            If Not cs.IsStartupScriptRegistered(cstype, csname1) Then
                Dim cstext1 As New StringBuilder()
                cstext1.Append("<script type=text/javascript> alert('Only members!') </")
                cstext1.Append("script>")
                cs.RegisterStartupScript(cstype, csname1, cstext1.ToString())
            End If
      Response.Redirect("Default.aspx?ID=1")
End If

I'm using master page.

My problem is that my alert never shows. But if i remove the Redirect, there is no problem?

I'm using the exact same code on many other pages without any problems? how can that be?

0
Comment
Question by:DCRAPACCESS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
Swapnil Piparia earned 2000 total points
ID: 34881705
Hi DCRAPACCESS,

      That's true. The reason is it register script on your current page. However before that page renders you are redirecting it to another page. So script will not get executed.

      are you doing redirect on other pages too after registering script block?
 
Thanks,
netswap
0
 

Author Comment

by:DCRAPACCESS
ID: 34881738
Hi netswap, i'm almost positive that i'm also doing the same on other pages too. But I found another way around. Instead of calling the script on the page i have troubles with, i'm using a session and then open the message from the master page instead and that works fine.

But you are 100% right about your comment about the rendering, that were the difference.

Thanks for your answer!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 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