S
Simon Harris
Hi All,
I'm trying to write a composite web control which will render a rich text
editor.
I am having problems with RegisterClientScriptBlock - The script simply
doesnt get written. There are no errors compiling the code. Strangly, if I
use RegisterClientScriptBlock, the script gets written to the page, but
the
script is then in the wrong place - The script gets run before the page is
rendered.
Heres the relevent chunk of my code:
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
'Javascript
Dim strJSScriptKey As String = "RichEditorJS"
If Page.IsClientScriptBlockRegistered(strJSScriptKey) = False Then
strJavascript =
GetFileContents(HttpContext.Current.Server.MapPath("/richeditorfiles") &
"/richeditor.js")
Page.RegisterClientScriptBlock(strJSScriptKey, "<script
language=javascript>alert('Woot');</script>")
End If
'VBScript
Dim strVBSScriptKey As String = "RichEditorVBS"
If Page.IsClientScriptBlockRegistered(strVBSScriptKey) = False
Then
strVBScript =
GetFileContents(HttpContext.Current.Server.MapPath("/richeditorfiles") &
"/richeditorvbs.txt")
Page.RegisterClientScriptBlock(strVBSScriptKey, "<script>" &
strVBScript & "</script>")
End If
I have read something about using PreRender - The article wasnt entirely
relevent, and didnt give an example, but PreRender sounded perhaps useful?
Thanks!
Simon.
I'm trying to write a composite web control which will render a rich text
editor.
I am having problems with RegisterClientScriptBlock - The script simply
doesnt get written. There are no errors compiling the code. Strangly, if I
use RegisterClientScriptBlock, the script gets written to the page, but
the
script is then in the wrong place - The script gets run before the page is
rendered.
Heres the relevent chunk of my code:
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
'Javascript
Dim strJSScriptKey As String = "RichEditorJS"
If Page.IsClientScriptBlockRegistered(strJSScriptKey) = False Then
strJavascript =
GetFileContents(HttpContext.Current.Server.MapPath("/richeditorfiles") &
"/richeditor.js")
Page.RegisterClientScriptBlock(strJSScriptKey, "<script
language=javascript>alert('Woot');</script>")
End If
'VBScript
Dim strVBSScriptKey As String = "RichEditorVBS"
If Page.IsClientScriptBlockRegistered(strVBSScriptKey) = False
Then
strVBScript =
GetFileContents(HttpContext.Current.Server.MapPath("/richeditorfiles") &
"/richeditorvbs.txt")
Page.RegisterClientScriptBlock(strVBSScriptKey, "<script>" &
strVBScript & "</script>")
End If
I have read something about using PreRender - The article wasnt entirely
relevent, and didnt give an example, but PreRender sounded perhaps useful?
Thanks!
Simon.