Ask a Question related to ASP.NET General, Design and Development.
-
Simon Storr #1
Re: click event does not occur in webusercontrol
I have EXACTLY the same problem - its a catch 22 which I've not yet found an
answer to :o( You can't seem to attach events in PreRender (in fact it only
seems to work if you Add the control in PageLoad, which as you say is too
early... Anyone from Microsoft care to shed any light on the problem? It is
bringing our development to a complete halt :o(
thanks,
Simon
"Bisser Milanov" <bm@bm.bm> wrote in message
news:#iRLhUENDHA.2204@TK2MSFTNGP12.phx.gbl...And> 1. I create a WebControlLibrary called wcl
> 2. I add the following code to the library
> Private WithEvents m_btn As New Button()
>
> Protected Overrides Sub Render(ByVal output As
> System.Web.UI.HtmlTextWriter)
> m_btn.RenderControl(output)
> End Sub
>
> Private Sub wcl_Init(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
> m_btn.Text = "test button"
> Me.Controls.Add(m_btn)
> End Sub
>
> 3. I create a test project called testwcl
> 4. In the test project I add WebUserControl1
> 5. I drag the wcl control from the toolbox to the WebUserControl
> 6. In the Default WebForm of the test project I put a placeholder - ph.Page_PreRender> a button - Button1
>
> Here comes the trick.
> If I put the following code
> ph.Controls.Add(LoadControl("WebUserControl1.ascx" ))
>
> in the event Page_Load of the WebForm and I run the project - it works.
> Which is I see the WebUserControl on the WebForm and if I press the button
> constructed from the library I receive the event Click in the library.
>
> But if I move the above mentioned piece of code in the eventthe> or Button1_Click then it does not work. Which is I run the project pressWHY?> button constructed from the library and the click event does not occur.in>
> So actually it appears that it works properly only if I load the controlto> the Load event. But I can't do that because I want to add different
> webusercontrol at runtime. And in runtime if I have a combobox from whichdon't> select which control to be loaded and do the load on bombo_click the I> receive the button_click events in the library!!!
>
> Any suggestions?
>
>
>
Simon Storr Guest
-
CreateChildControls Event before Click Event
Issue: I want to create a control that will accept a click event and then in response completely change it's look and feel. This could potentially... -
double click causes click-event anddoubleClick-event
I too am interested in a response to this. I see all kinds of information on how to enable the double-click event, but not how to distinguish... -
stumped...table - row - click event, cancel checkbox event
I have a html table and mutliple rows. On each row i put an onclick event that opesn a modal window and prompts the user for some information. I... -
Click Event Not Firing
In Framework 1.1 (VS 2003, C#) I've written a server control that contains a button. If I place the control on a page surface, it renders fine and... -
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl.
Hello I have the following situation: (everything is dynamic (controls.add)) 1. Button.Init { WasButtonClickFired = true } 2....



Reply With Quote

