Solved

RegisterStartupScript from ASP.NET Content Page

Posted on 2011-02-23
4
514 Views
Last Modified: 2012-05-11
I have been re-writing a web application which used frames to use a master/content page architecture and have run into an odd problem.

Within a content page I have a form which the user complets and then clicks a 'Save' button.  This posts back to the server where some additional validation is performed and depending on the results I want to display a message to the user.  

The previous version had a JavaScript function 'ReportSaved' in the page which was called from the server side button handler using ClientScript.RegisterStartupScript which all worked perfectly.  This stopped working as soon as I started using master pages,

I have now simplified this within my button onclick handler to :-

const string alertScript = "alertSaveChanges";
if (!ClientScript.IsStartupScriptRegistered(this.GetType(), alertScript))
    ClientScript.RegisterStartupScript(this.GetType(), alertScript, "alert('help!!!');", true);

I can step through this and it all seems to work but my alert is not displayed.  Cionfused now so any help appreciated.

Also when I view the source after this call I cannot see the alert in the page source which I would expect to from memory of how it worked previously.

0
Comment
Question by:ChrisMDrew
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
Try using "Page.GetType()" rather than "this.GetType()"
0
 
LVL 4

Expert Comment

by:jmnf
Comment Utility
Re-load js script on child page, usually js from master pages do not work after postback
0
 

Accepted Solution

by:
ChrisMDrew earned 0 total points
Comment Utility
My error - the problem is down to the fact that the containiong control (an Infragistics WebTab) has Ajax enabled.  This is preventing the script from being added as the page is not being posted back fully.
0
 

Author Closing Comment

by:ChrisMDrew
Comment Utility
Sorry for those who suggested a solution - the problem is not actually as detailed but is an Ajax issue.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

11 Experts available now in Live!

Get 1:1 Help Now