Solved

RegisterStartupScript from ASP.NET Content Page

Posted on 2011-02-23
4
522 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 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