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

2 posts, 0 answers
  1. ReinelOchoa
    ReinelOchoa avatar
    1 posts
    Member since:
    Aug 2011

    Posted 24 Aug 2012 Link to this post

    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”

  2. Eyup
    Admin
    Eyup avatar
    3662 posts

    Posted 28 Aug 2012 Link to this post

    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.
Back to Top