scalf Posted June 28, 2005 Posted June 28, 2005 (edited) Hello All, I created an aspx page in which I have a nested user control containing a dynamically created button. The problem is that everytime I click on it, the codebehind is not executed. It doesn't even enter in the code. The button was working before and I don't know what makes it bug . Here is the begining of the .aspx page : <%@ Register TagPrefix="uc1" TagName="Layout" Src="/User_Controls/Layout.ascx" %> <uc1:Layout id="ucLayout" ShowConsole=True RightColumn=False runat="server"> <CentreTemplate> ... some code ... <asp:Button id="btnModify" runat="server" Text="Modify" Font-Size="XX-Small" Font-Names="Verdana,Arial" BorderStyle="Outset"></asp:Button> .... some code ... </CentreTemplate> </uc1:Layout> Then in the CodeBehind I have this : At the top of the page : Protected WithEvents btnModify As System.Web.UI.WebControls.Button in The PageLoad : btnModify = CType(ucLayout.FindControl("btnModify"), Button) Then I have the click command of the button : Public Sub btnModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnModify.Click ...some code .... End Sub Can someone help me find why my btnModify_Click is not executed. I tried with an Hyperlink Button and it works. Why the simple button control doesn't want to work ? Many Thanks. Edited June 28, 2005 by scalf Quote Scalf. Do not want others to know what you have done? Better not have done it anyways.
bri189a Posted June 29, 2005 Posted June 29, 2005 You do not need the following line: btnModify = CType(ucLayout.FindControl("btnModify"), Button) This is probably unsetting the control and causing the error. Quote
scalf Posted June 29, 2005 Author Posted June 29, 2005 No, removing the line btnModify = CType(ucLayout.FindControl("btnModify"), Button) does not change anything... Any other idea ? Many thanks. NB : Can it be the Framework 1.1 version which is bugging ? Quote Scalf. Do not want others to know what you have done? Better not have done it anyways.
bri189a Posted June 29, 2005 Posted June 29, 2005 Can you zip the page and code behind and post it, I'll look at it later on, or one of the other guys will. Quote
scalf Posted June 29, 2005 Author Posted June 29, 2005 OK many thanks, here is the aspx page and .vb code. Sorry, the variables and functions have French names...I hope it will not be a problem. Many thanks for all of you!!! Quote Scalf. Do not want others to know what you have done? Better not have done it anyways.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.