Solved

RegisterStartupScript from ASP.NET Content Page

Posted on 2011-02-23
4
523 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
[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
4 Comments
 
LVL 52

Expert Comment

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

Expert Comment

by:jmnf
ID: 34965632
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
ID: 34968637
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
ID: 35005085
Sorry for those who suggested a solution - the problem is not actually as detailed but is an Ajax issue.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

622 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