I need to create some controls dynamically from code behind, and then, I need to add a JavaScript code to this control.. something like this:
Dim radTextbox As Telerik.Web.UI.RadTextBox
radTextbox = New Telerik.Web.UI.RadTextBox
radTextbox.TextMode = Telerik.Web.UI.InputMode.SingleLine
radTextbox.ID = drRow.item("CampoAlias") 'Name added dynamically
radTextbox.EnableViewState = False
radTextbox.Width = "200"
radTextbox.ClientEvents.OnValueChanged = "Titulo___onChange()" 'Function name added dynamically
Dim strString as string 'code will be added dynamically too
strString = "<script type='text/javascript'>"
strString +=" function Titulo___onChange() { alert(' Hello!!!'); }"
strString +="</script>"
//here I have to add the javascript code to the page… how???? I don’t now!!!
// how can I be sure the postback will work very well too.
Other option I tested and It didn’t work out:
------------------------------------------------------------------
I need to create some controls dynamically from code behind, and then, I need to add a JavaScript code to this control.. something like this:
Dim radTextbox As Telerik.Web.UI.RadTextBox
radTextbox = New Telerik.Web.UI.RadTextBox
radTextbox.TextMode = Telerik.Web.UI.InputMode.SingleLine
radTextbox.ID = drRow.item("CampoAlias") 'Name added dynamically
radTextbox.EnableViewState = False
radTextbox.Width = "200"
radTextbox.ClientEvents.OnValueChanged = "Titulo___onChange()" 'Function name added dynamically
Dim scriptText As String = ""
scriptText = "function Titulo___onChange(){"
scriptText += " alert(' Hello '); "
scriptText += " }"
ClientScript.RegisterClientScriptBlock(Me.GetType(), "CounterScript", scriptText, True)
‘The first execution work out well, but in the postback send a error: “Microsoft JScript runtime error: Object expected”