PC Review


Reply
Thread Tools Rate Thread

Dinamically created webcontrol does not fire events

 
 
=?Utf-8?B?Sm9yZ2UgUmliZWlybw==?=
Guest
Posts: n/a
 
      24th May 2007
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      24th May 2007
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

 
Reply With Quote
 
=?Utf-8?B?Sm9yZ2UgUmliZWlybw==?=
Guest
Posts: n/a
 
      25th May 2007
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dinamically Created WebControls =?Utf-8?B?SW5mb3NweQ==?= Microsoft Dot NET 0 13th Mar 2006 03:47 PM
Create and display a Webcontrol created dinamically Cesar Ronchese Microsoft VB .NET 4 23rd Dec 2005 08:22 PM
Dynamically created webcontrol's events not firing Mark Rae Microsoft ASP .NET 3 24th Sep 2005 03:16 PM
How do I dinamically add controls and events to a Web Form vladvadeanu Microsoft ASP .NET 3 21st May 2004 03:52 PM
Problem with dinamically created controls Rafi Microsoft ASP .NET 0 1st Dec 2003 10:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:12 PM.