all groups > asp.net webcontrols > october 2003 >
You're in the asp.net webcontrols group:
Button_Click event in user control not firing on page
asp.net webcontrols:
Hello Tim, Just put a break point on the buttons click event in the code behind file. and step into it. look at the various condition in the watch windows maybe some conditions you thought didnt work that way. regards, HD [quoted text, click to view] "Tim Thomas" <broadbanned@hotmail.com> wrote in message news:bnq5v5$2anj$1@news.wplus.net... > Hi, > I am very new to .NET and am in the process of building my first web > application. > I will briefly describe what i am trying to achieve: > > I have a system where suppliers register their details, their locations, and > then add themselves to categories. Each category requires additional info > from the suppliers, this additional category info is stored in its own DB > table. a suppliers may add themselves to as many categories as required. > the registration process is as follows: > > 1. enter personal details > 2. select locations > 3 select category > 4 enter details for category > [upon successfully completing stage 4, option to go back to stage 3 and add > another category] > > I have got to stage 3 ok, > this page has a dropdownList (and a button) to select the category, on > button_Click a user control dynamically loads into a placeholder on the > page, all works fine. this is the simplified code: > > private void btnCategory_Click(object sender, System.EventArgs e) > { > Control myControl = LoadControl(DropDownList1.SelectedItem.Text.Replace > + ".ascx"); > PlaceHolder1.Controls.Add(myControl); > } > > the control this loads is a simple webform page that has a form the supplier > fills out and a button to 'send' the form (the button is within the .ascx > user control). the button event should then add all the form data to a > sqlCommand to add the text in each box to the stored procedure parameters. > All this needs to happen withing the user control because it's quite > different for each category. i hope your following me! > when the control button is clicked all that happens is the page (that hosts > the user control) reloads, the control dissapears, and the stored procedure > (part of the button_click method within the user control) doesn't execute, > and all i'm left with is the dropdown list again. > > What i need to happen is for the button_Click event to fire, do it's stuff > and inform the user they were added, and ask them if they would like to add > themselves to another category. > > I'm sure i am missing something fundamental and simple, but as i said i'm > quite new to all this. > > Any help is greatly appreciated. > > Thanks > Tim.. > >
Hi, I am very new to .NET and am in the process of building my first web application. I will briefly describe what i am trying to achieve: I have a system where suppliers register their details, their locations, and then add themselves to categories. Each category requires additional info from the suppliers, this additional category info is stored in its own DB table. a suppliers may add themselves to as many categories as required. the registration process is as follows: 1. enter personal details 2. select locations 3 select category 4 enter details for category [upon successfully completing stage 4, option to go back to stage 3 and add another category] I have got to stage 3 ok, this page has a dropdownList (and a button) to select the category, on button_Click a user control dynamically loads into a placeholder on the page, all works fine. this is the simplified code: private void btnCategory_Click(object sender, System.EventArgs e) { Control myControl = LoadControl(DropDownList1.SelectedItem.Text.Replace + ".ascx"); PlaceHolder1.Controls.Add(myControl); } the control this loads is a simple webform page that has a form the supplier fills out and a button to 'send' the form (the button is within the .ascx user control). the button event should then add all the form data to a sqlCommand to add the text in each box to the stored procedure parameters. All this needs to happen withing the user control because it's quite different for each category. i hope your following me! when the control button is clicked all that happens is the page (that hosts the user control) reloads, the control dissapears, and the stored procedure (part of the button_click method within the user control) doesn't execute, and all i'm left with is the dropdown list again. What i need to happen is for the button_Click event to fire, do it's stuff and inform the user they were added, and ask them if they would like to add themselves to another category. I'm sure i am missing something fundamental and simple, but as i said i'm quite new to all this. Any help is greatly appreciated. Thanks Tim..
Quick one Tim, The button is on a user control so how are you capturing the event. Think you'll have to go a bit deeper. With custom controls you have to inherit from IPostBackDataHandler and implement its RaisePostDataChangedEvent. I am still trying to figure out how to return the control to the control's container (Fire a custom event for the page possibly) so that any other manipulation other than that one the control goes through as well post the controls data manipulation, Dont think it will help to that an extent, HD [quoted text, click to view] "Tim T" <broadbanned@hotmail.com> wrote in message news:bnrqbu$2bt5$1@news.wplus.net... > Thanks HD, > I tried what you said, and it seems the code didn't even hit the breakpoint, > so i couldn't see why the button click event in the user controls code > behind wasn't firing > It seems to me that clicking the button (which is part of the user control) > on the page embedding the user control just reloads/does a post back for the > page [hosting the control]- it doesn't fire any of the events in the user > control :@ > Any other suggestions appreciated > > Tim.. > > "HD" <hermitdREMOVE@CAPShotmail.com> wrote in message > news:OrW5DKwnDHA.2820@TK2MSFTNGP10.phx.gbl... > > Hello Tim, > > > > Just put a break point on the buttons click event in the code behind file. > > and step into it. > > look at the various condition in the watch windows maybe some conditions > you > > thought didnt work that way. > > > > regards, > > > > HD > > > > "Tim Thomas" <broadbanned@hotmail.com> wrote in message > > news:bnq5v5$2anj$1@news.wplus.net... > > > Hi, > > > I am very new to .NET and am in the process of building my first web > > > application. > > > I will briefly describe what i am trying to achieve: > > > > > > I have a system where suppliers register their details, their locations, > > and > > > then add themselves to categories. Each category requires additional > info > > > from the suppliers, this additional category info is stored in its own > DB > > > table. a suppliers may add themselves to as many categories as required. > > > the registration process is as follows: > > > > > > 1. enter personal details > > > 2. select locations > > > 3 select category > > > 4 enter details for category > > > [upon successfully completing stage 4, option to go back to stage 3 and > > add > > > another category] > > > > > > I have got to stage 3 ok, > > > this page has a dropdownList (and a button) to select the category, on > > > button_Click a user control dynamically loads into a placeholder on the > > > page, all works fine. this is the simplified code: > > > > > > private void btnCategory_Click(object sender, System.EventArgs e) > > > { > > > Control myControl = > > LoadControl(DropDownList1.SelectedItem.Text.Replace > > > + ".ascx"); > > > PlaceHolder1.Controls.Add(myControl); > > > } > > > > > > the control this loads is a simple webform page that has a form the > > supplier > > > fills out and a button to 'send' the form (the button is within the > .ascx > > > user control). the button event should then add all the form data to a > > > sqlCommand to add the text in each box to the stored procedure > parameters. > > > All this needs to happen withing the user control because it's quite > > > different for each category. i hope your following me! > > > when the control button is clicked all that happens is the page (that > > hosts > > > the user control) reloads, the control dissapears, and the stored > > procedure > > > (part of the button_click method within the user control) doesn't > execute, > > > and all i'm left with is the dropdown list again. > > > > > > What i need to happen is for the button_Click event to fire, do it's > stuff > > > and inform the user they were added, and ask them if they would like to > > add > > > themselves to another category. > > > > > > I'm sure i am missing something fundamental and simple, but as i said > i'm > > > quite new to all this. > > > > > > Any help is greatly appreciated. > > > > > > Thanks > > > Tim.. > > > > > > > > > > > >
Thanks HD, I tried what you said, and it seems the code didn't even hit the breakpoint, so i couldn't see why the button click event in the user controls code behind wasn't firing It seems to me that clicking the button (which is part of the user control) on the page embedding the user control just reloads/does a post back for the page [hosting the control]- it doesn't fire any of the events in the user control :@ Any other suggestions appreciated Tim.. [quoted text, click to view] "HD" <hermitdREMOVE@CAPShotmail.com> wrote in message news:OrW5DKwnDHA.2820@TK2MSFTNGP10.phx.gbl... > Hello Tim, > > Just put a break point on the buttons click event in the code behind file. > and step into it. > look at the various condition in the watch windows maybe some conditions you > thought didnt work that way. > > regards, > > HD > > "Tim Thomas" <broadbanned@hotmail.com> wrote in message > news:bnq5v5$2anj$1@news.wplus.net... > > Hi, > > I am very new to .NET and am in the process of building my first web > > application. > > I will briefly describe what i am trying to achieve: > > > > I have a system where suppliers register their details, their locations, > and > > then add themselves to categories. Each category requires additional info > > from the suppliers, this additional category info is stored in its own DB > > table. a suppliers may add themselves to as many categories as required. > > the registration process is as follows: > > > > 1. enter personal details > > 2. select locations > > 3 select category > > 4 enter details for category > > [upon successfully completing stage 4, option to go back to stage 3 and > add > > another category] > > > > I have got to stage 3 ok, > > this page has a dropdownList (and a button) to select the category, on > > button_Click a user control dynamically loads into a placeholder on the > > page, all works fine. this is the simplified code: > > > > private void btnCategory_Click(object sender, System.EventArgs e) > > { > > Control myControl = > LoadControl(DropDownList1.SelectedItem.Text.Replace > > + ".ascx"); > > PlaceHolder1.Controls.Add(myControl); > > } > > > > the control this loads is a simple webform page that has a form the > supplier > > fills out and a button to 'send' the form (the button is within the ..ascx > > user control). the button event should then add all the form data to a > > sqlCommand to add the text in each box to the stored procedure parameters. > > All this needs to happen withing the user control because it's quite > > different for each category. i hope your following me! > > when the control button is clicked all that happens is the page (that > hosts > > the user control) reloads, the control dissapears, and the stored > procedure > > (part of the button_click method within the user control) doesn't execute, > > and all i'm left with is the dropdown list again. > > > > What i need to happen is for the button_Click event to fire, do it's stuff > > and inform the user they were added, and ask them if they would like to > add > > themselves to another category. > > > > I'm sure i am missing something fundamental and simple, but as i said i'm > > quite new to all this. > > > > Any help is greatly appreciated. > > > > Thanks > > Tim.. > > > > > >
Don't see what you're looking for? Try a search.
|
|
|