Click to See Complete Forum and Search --> : runs at server Question


Limor Janah
July 8th, 2003, 03:46 AM
Hi
I have a web control asp:textbox runat=server
I want to add a client side script that handles the OnTextChanged event
but I’m getting an error:
'myScriptFunc' is not a member of 'ASP.myPageName_aspx'

I understand that the page search for the method at the server side

How do I add a client side code to a web control that runs at server?

Thanks
Limor

DSJ
July 8th, 2003, 10:08 AM
Page will need Table1, and Label1

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

x = New Button()
x.Text = "Test Button"
x.ID = "MyButtonID2"
x.Attributes.Add("onclick", "javascript:alert('hello - this is from the client side!!')")
AddHandler x.Click, AddressOf DynamicClick
Me.Table1.Rows(0).Cells(0).Controls.Add(x)

End Sub
Public Sub DynamicClick(ByVal sender As Object, ByVal e As System.EventArgs)
Dim b As Button
b = CType(sender, System.Web.UI.WebControls.Button)
Label1.Text = "This is from server side -- You Clicked the Button! - " & sender.id & " "
End Sub

Limor Janah
July 9th, 2003, 12:41 AM
Thanks