Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Cameron Eckman #1
RegisterClientScriptBlock does not work from a server control
For some reason I cannot get RegisterClientScriptBlock to render a script
reference on the page from a server control. Yes, I have not placed the code
in the Render method, I also tried the OnInit just in case. Below is the a
simple version of the code, any help is appreciated:
namespace MyCompany.Web
{
public class Header : System.Web.UI.WebControls.WebControl
{
private void RenderClientJavaScript(string javaScriptFilename)
{
string script = string.Format(@"<SCRIPT language=""javascript""
src=""/baxScripts/{0}.js""></SCRIPT>", javaScriptFilename);
if (! Page.IsClientScriptBlockRegistered(javaScriptFilen ame))
Page.RegisterClientScriptBlock(javaScriptFilename, script);
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
RenderClientJavaScript("basicToolset");
RenderClientJavaScript("webMenu");
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("Hello World");
}
}
}
Cameron Eckman Guest
-
RegisterClientScriptBlock with rendered control?
Hi, Are there any issues using ClientScriptManager.RegisterClientScriptBlock in a rendered control? I'm calling this function within the... -
ClientScript.RegisterClientScriptBlock in ASP.NET 2.0
I am working on converting my code from ASP.NET 1.1 to ASP.NET 2.0. In ASP.NET 1.1 the RegisterClientScriptBlock method was just a key and script... -
Where is Page.RegisterClientScriptBlock Available?
I have used the RegisterClientScriptBlock method in external functions of mine (ones that are saved in a separate *.vb file), where I use them as... -
Where is RegisterClientScriptBlock?? RegisterScripts etc.
Hello, Where can I find RegisterClientScriptBlock() Page class does not have it. Do I have to Import or add some special reference?? what... -
control equivalent to Page.RegisterClientScriptBlock?
I have a user control that can be created from a variety of other user controls. It is the same no matter where it is created from, and I only... -
recoil@community.nospam #2
Re: RegisterClientScriptBlock does not work from a server control
I would place my money on RenderClientJavaScript not getting called.
I do not believe the fact that you are not calling base.Render should
effect the actual rendering of the JavaScript so double check that
RenderClientJavaScript is actually getting called at the appropriate
time. You can do this if you are using VS.NET and debugging locally
simply by placing a breakpoint there and then running the web app in
debug mode. .
recoil@community.nospam Guest



Reply With Quote

