Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 17th, 2006, 03:07 PM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default User Control Not Fired in ASP.NET 2.0

I was planning to use user controls to handle page navigation. If a control is not related to any click events, the control works fine. However, if a user control requires to fire an event, such as click. The event is never fired. The following is a simple user control code:

<%@ Control Language="C#" ClassName="TestUserControl" %>

<script lang="C#" runat="server" >

    public void imgTest1_Click(object sender, EventArgs e)
    {
    txtTest1.Text = "HI there";
    }
</script>
<asp:TextBox ID="txtTest1" runat="server" />
<asp:ImageButton ID="imgTest1" ImageUrl="~\Images\PageSize.gif" OnClick="imgTest1_Click" runat="server" />

The way to load the control is control as below:

        workPage = LoadControl(ctlurl);
        this.WorkArea.Controls.Add(workPage);

where WorkArea is my placeholder in my web page and ctlurl is pointed to the file path of my user control. If I click the image button, it looks like the page was posted back but displays nothing (blank). Can anyone provide any clues why an event does not fire in a user control. I have tried all combinations of "Reference" directive, ClassName in the User Control, programatically add the event in OnInit. But none is working. I know I must miss a simple hook somewhere??????

Thanks for your help!

Jwang






Similar Threads
Thread Thread Starter Forum Replies Last Post
What if I need control value before event is fired pauliehaha ASP.NET 3.5 Basics 9 May 22nd, 2008 12:51 PM
how to use asp.net we user control on asp 3.0 web i_shahid Java Basics 2 January 8th, 2008 09:04 AM
using asp.net web user control in asp 3.0 App i_shahid Classic ASP Professional 0 January 8th, 2008 07:32 AM
using jscript in with a .net user control Morrislgn Javascript How-To 0 April 2nd, 2004 12:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.