locked
Attribute query in custom control RRS feed

  • Question

  • User-203096317 posted

    I am writing a custom  composite control. Using an embedded .js file and attributes i can my control (primarily a textbox) to behave as expected. I have added the following attributes to the control during the OnInit event of the control.

        Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
            MyBase.OnInit(e)
            Me.Attributes.Add("onkeydown", "javascript:return fName(this, event);")
        End Sub

     the function fName is in my javascript file and returns the expected result.

    The problem i am having is when i attempt to add an attribute for "ondrop" instead of the onkeydown event, nothing happens. The event doesn't seem to be firing.

        Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
            MyBase.OnInit(e)
            Me.Attributes.Add("ondrop", "javascript:return fName(this, event);")
        End Sub
     If i use my control in a page and add the attribute to fire on the onDrop event maunally during the page load to a specified instance of my control it works as expected.

    I've tried variations of upper and lower case but no joy. Does anyone know how i can fix this or give me a reason why it doesn't seem to work?

    thanks.

    Tuesday, March 18, 2008 11:46 AM

All replies

  • User2032526919 posted

    Have you checked the rendered markup (view source in browser), is the attribute rendered normally on such case, when it doesn't work?

    Tuesday, March 18, 2008 12:11 PM
  • User-203096317 posted

    thanks for the swift response joteke. I'm a bit emabrrassed, but it all seems to be working as expected now. I can't see where i've made any modifications, but now the function fires when expected with no issues.

    Tuesday, March 18, 2008 12:51 PM