Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
ClientScript.IsStartupScriptRegistered() from Web Control
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Jonathan Wood, post: 3852471"] I'm designing a control that will render some additional HTML content exactly once per page, regardless of the number of instances of the control on that page. Thanks to Mr. Niver's suggestions, I got this working by calling Page.ClientScript.IsStartupScriptRegistered() from my control's Load event and writing that additional HTML content from the control only when IsStartupScriptRegistered() returns false. This seemed to be working just fine from a Web User Control. But I'm now moving my control to a regular Web control. The first problem is that the Control has no Load event. One of my books shows a control initializing itself in the OnInit() override so I tried my code there: protected override void OnInit(EventArgs e) { // ... _createHiddenField = false; if (!Page.ClientScript.IsStartupScriptRegistered("OrderCartRequest")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "OrderCartRequest", "function dummy() {}", true); _createHiddenField = true; } // ... } I placed five instances of this control on a page and set a breakpoint in the code above. I see that Page.ClientScript.IsStartupScriptRegistered() returns false when it is called each of the five times from each instance of my control. Obviously, I expect false to be returned only for the first instance of the control. Can anyone see what I'm missing? Thanks. Jonathan [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
ClientScript.IsStartupScriptRegistered() from Web Control
Top