Solved

Problem with RegisterStartupScript

Posted on 2011-02-12
2
476 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
2 Comments
 
LVL 16

Accepted Solution

by:
Swapnil Piparia earned 500 total points
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now