473,387 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dinamically created webcontrol does not fire events

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
May 24 '07 #1
2 1816
Do you want to post a "short but complete" piece of sample code illustrating
the problem? Particularly, the part where you "To do so i try to bind the
button's Click event to a procedure but it never fires..."

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Jorge Ribeiro" wrote:
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
May 24 '07 #2
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
"Peter Bromberg [C# MVP]" wrote:
Do you want to post a "short but complete" piece of sample code illustrating
the problem? Particularly, the part where you "To do so i try to bind the
button's Click event to a procedure but it never fires..."

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Jorge Ribeiro" wrote:
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
May 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Umut Tezduyar | last post by:
public class WebForm1 : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { }
0
by: Lucas, Todd | last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing for a Menu. I've been at it for about 3 weeks now, and can't seem to get around this problem. So I'm hoping that someone...
2
by: JezB | last post by:
I'm adding WebControl objects to a Page dynamically on Page_Load, but I'm having trouble attaching events to these. For example, adding an image button :- ImageButton nb = new ImageButton();...
3
by: Mark Rae | last post by:
Hi, I'm sure I've done this before, but I can't get it to work today... I'm trying to add a DropDownList into a TableCell and wire up its SelectedIndexChanged event. I'm adding the dynamic...
2
by: Amelyan | last post by:
I *finally* narrowed down my problem to my custom web control. If I hookup event inside dynamically created custom web control, it doesn't get fired. However, event gets fired for any other...
2
by: MLS | last post by:
The documentation on dynamic handlers comes across as abiguous. Perhaps somebody could help set me straight? I have a situation where I need to dynamically create several usercontrols of the...
4
by: Cesar Ronchese | last post by:
Hello. I have a WebForm that contains a Panel object. This panel, at design time is empty. When running, I need to create dinamically a Label and a WebControl (built from the same project). I...
5
by: Steve Moreno | last post by:
Hi all, I've got a web form that I've written code to create an array of DropDownList controls on the page depending on how many records are pulled back. The code to create the controls is...
2
by: Peregrin | last post by:
Hello world. I will try to explain my problem. I've a webcontrol with an interface which provides a choice of methods. After including the webcontrol in a special aspx page, I want to call an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.