Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > UserControl click event won't fire

Reply
Thread Tools

UserControl click event won't fire

 
 
Mark Sisson
Guest
Posts: n/a
 
      12-02-2003
I've got a custom usercontrol (UC1) that dynamically loads another
custom usercontrols (UC2) during it's Init event. Both controls have
LinkButtons with click events. The LinkButton from UC1 properly goes
to it's click-event handler but the LinkButton from UC2 does not fire
it's associated click event.


Are there problem in having nested Usercontrols fire events if they're
created through code?

TIA
 
Reply With Quote
 
 
 
 
Thijs
Guest
Posts: n/a
 
      12-02-2003
I think you're experiencing the same problem as I am. The problem is that
ASP.NET is unable to restore the viewstate of a dynamically loaded control
after a postback. I'm searching for a way to do this manually now.

Regards,

Thijs

"Mark Sisson" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed) om...
> I've got a custom usercontrol (UC1) that dynamically loads another
> custom usercontrols (UC2) during it's Init event. Both controls have
> LinkButtons with click events. The LinkButton from UC1 properly goes
> to it's click-event handler but the LinkButton from UC2 does not fire
> it's associated click event.
>
>
> Are there problem in having nested Usercontrols fire events if they're
> created through code?
>
> TIA



 
Reply With Quote
 
 
 
 
Chris Thayer
Guest
Posts: n/a
 
      12-10-2003
This should work correctly. I created an example like you described and it
worked as expected. Here is the source of UC1:

<%@ control language="C#" classname="WebUserControl"%>
<%@ register tagprefix="uc" tagname="uc2" src="~/WebUserControl2.ascx" %>

<script runat="server">
protected override void OnInit(EventArgs e)
{
WebUserControl2 uc2 =
(WebUserControl2)LoadControl("WebUserControl2.ascx ");
Controls.Add(uc2);
base.OnInit(e);
}

void LinkButton1_Click(object sender, EventArgs e)
{
Page.Response.Write("this is from LinkButton1_Click<br>");
}

</script>

<asp:linkbutton runat="server" id="LinkButton1" onclick="LinkButton1_Click"
>LinkButton1</asp:linkbutton><br />


and this is the source of UC2:

<%@ control language="C#" classname="WebUserControl2"%>

<script runat="server">

void LinkButton2_Click(object sender, EventArgs e)
{
Page.Response.Write("this is from LinkButton2_Click<br>");
}
</script>

<asp:linkbutton runat="server" id="LinkButton2" onclick="LinkButton2_Click"
>LinkButton2</asp:linkbutton>


Hope that helps,
Chris Thayer
--------------------
>From: http://www.velocityreviews.com/forums/(E-Mail Removed) (Mark Sisson)
>Newsgroups:

microsoft.public.dotnet.framework.aspnet.buildingc ontrols,microsoft.public.d
otnet.framework.aspnet.webcontrols
>Subject: UserControl click event won't fire
>Date: 2 Dec 2003 08:03:04 -0800
>Organization: http://groups.google.com
>Lines: 11
>Message-ID: <(E-Mail Removed) >
>NNTP-Posting-Host: 68.99.177.203
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1070380984 8237 127.0.0.1 (2 Dec 2003 16:03:04

GMT)
>X-Complaints-To: (E-Mail Removed)
>NNTP-Posting-Date: Tue, 2 Dec 2003 16:03:04 +0000 (UTC)
>Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!newsfee
d01.sul.t-online.de!t-online.de!fu-berlin.de!postnews1.google.com!not-for-ma
il
>Xref: cpmsftngxa06.phx.gbl

microsoft.public.dotnet.framework.aspnet.webcontro ls:16577
microsoft.public.dotnet.framework.aspnet.buildingc ontrols:8322
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>
>I've got a custom usercontrol (UC1) that dynamically loads another
>custom usercontrols (UC2) during it's Init event. Both controls have
>LinkButtons with click events. The LinkButton from UC1 properly goes
>to it's click-event handler but the LinkButton from UC2 does not fire
>it's associated click event.
>
>
>Are there problem in having nested Usercontrols fire events if they're
>created through code?
>
>TIA
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

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
How to fire both event button click and textchanged when button is click and text is changed Amy ASP .Net 0 06-01-2006 02:33 PM
first click wont fire on dynamic load of usercontrol roni ASP .Net 2 08-07-2005 01:12 AM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
UserControl click event won't fire Mark Sisson ASP .Net Building Controls 1 12-02-2003 06:43 PM
UserControl click event won't fire Mark Sisson ASP .Net Web Controls 0 12-02-2003 04:03 PM



Advertisments