Dinamically created webcontrol does not fire events

G

Guest

hello

Inside a usercontrol i create a webcontrol button.
I then render it onto a string on the usercontrol to built my UI
I need to get access to that control Click event. To do so i try to bind the
button's Click event
to a procedure but it never fires...

When the client is viewing the page that has the control in it, and click
the button, the page does the postback, the control passes to the usercontrol
code but never fires my click event of the clicked button.


can you assist me here

regards

Jorge
 
G

Guest

in the usercontrol, where my btn_doss button is created, the relevant code is:

...in InitComponent sub

btn_doss = New WebControls.Button
btn_doss.ID = "btn_doss"
btn_doss.CausesValidation = False
btn_doss.Attributes.Add("class", "textBox")
btn_doss.Text = "Save"

Dim handler As New EventHandler(AddressOf btn_doss_Click)
AddHandler btn_doss.Click, handler


... in the property called by the page where the usercontrol is used

public property prt_doss () as integer
...
btn_doss.RenderControl(htmlText)

... i then write the content of htmlText into a span.innerHtml
attribute


.... the supposed event handler for btn_doss.click()

Private Sub btn_doss_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim i As Integer = 10 ' example
End Sub


In the webform page where i put my usercontrol the code is:


Protected WithEvents usr_int As usr_interveniente

.... in page preRender

usr_int.prt_doss=10

The usercontrol is rendered ok, when i click the doss_button the page is
postbacked but the event btn_doss_click is never fired...

I suspect that it is related whith control render in my usercontrol but i
have to do the things that way...

any help?!

thanx

Jorge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top