This is a migrated thread and some comments may be shown as answers.

I need to create some controls dynamically from code behind, and then, I need to add a JavaScript code to this control..

1 Answer 115 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ReinelOchoa
Top achievements
Rank 1
ReinelOchoa asked on 24 Aug 2012, 02:13 PM

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”

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 28 Aug 2012, 01:19 PM
Hello Reinel,

I have already replied to you in the other post, however, I will re-attach the web site for others who may face similar issues.

I hope this will prove helpful.

Kind regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
ReinelOchoa
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or