|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Command button won't cause postbackI've created a user control (C#) and added it to a web form. The user
control has a command button. When the button is clicked, nothing happens. I thought maybe something went wrong with the control, so I recreated it from scratch. Same problem. If I replace the command button with a link button, it will submit the form, but none of the user's changes to controls are available. For example, if a user selects an option in a RadioButtonList, the SelectedItem is still null. My project is made up of 20-30 user controls, and this is the only case where I'm having this problem. It's one of the strangest things I've seen lately. Any ideas? Thanks! 1- How do you add the control to your page? During which event of the page?
2- How did you handle the Command event of the Button? Show quoteHide quote "JAdrianB" wrote: > I've created a user control (C#) and added it to a web form. The user > control has a command button. When the button is clicked, nothing happens. > I thought maybe something went wrong with the control, so I recreated it from > scratch. Same problem. If I replace the command button with a link button, > it will submit the form, but none of the user's changes to controls are > available. For example, if a user selects an option in a RadioButtonList, > the SelectedItem is still null. My project is made up of 20-30 user > controls, and this is the only case where I'm having this problem. It's one > of the strangest things I've seen lately. Any ideas? Thanks! > Just drag-and-drop the button onto the User Control, then double-click the
button to enter code for the code-behind click event (as I've done thousands of times before). Then, drag-and-drop the UserControl onto the ASPX page. When the button is clicked, nothing happens, so it doesn't even try to execute any event at all on the server, or post the form. I'm generally adding UserControls to the ASPX page dynamically at runtime from the PageLoad event of the ASPX page. But whether I do it dynamically, or as described above, the behavior is identical. It may be related to the containing ASPX page. I dropped the control on a different web form and it seemed to work okay. It's very odd. Then I dropped a button control directly on the containing ASPX page, and it also didn't work. Show quoteHide quote "Phillip Williams" wrote: > 1- How do you add the control to your page? During which event of the page? > 2- How did you handle the Command event of the Button? > -- Ok, this is getting more odd as I go. After playing with the page, here's
something I discovered... There are two controls embedded in a table. One is a placeholder that I dynamically add controls to at runtime. The next is the user control I'm having problems with. If I put the Placeholder first, like below, the second control does not work properly: <asp:PlaceHolder ID="column1" Runat="server"></asp:PlaceHolder><br> <uc1:Poll id="Poll1" runat="server"></uc1:Poll> However, if I list the user control BEFORE the placeholder, it DOES work properly: <uc1:Poll id="Poll1" runat="server"></uc1:Poll> <asp:PlaceHolder ID="column1" Runat="server"></asp:PlaceHolder><br> Show quoteHide quote "Phillip Williams" wrote: > 1- How do you add the control to your page? During which event of the page? > 2- How did you handle the Command event of the Button? > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "JAdrianB" wrote: > > > I've created a user control (C#) and added it to a web form. The user > > control has a command button. When the button is clicked, nothing happens. > > I thought maybe something went wrong with the control, so I recreated it from > > scratch. Same problem. If I replace the command button with a link button, > > it will submit the form, but none of the user's changes to controls are > > available. For example, if a user selects an option in a RadioButtonList, > > the SelectedItem is still null. My project is made up of 20-30 user > > controls, and this is the only case where I'm having this problem. It's one > > of the strangest things I've seen lately. Any ideas? Thanks! > >
GridView and XmlDataSource
Using Validators as field labels DropDownList and Spaces Trouble removing cookies Animated buttons control? Trouble with DataList Control Trouble with the DataList Control newrow ID with detailsview and objectdatasource GridView DataFormatString only works on Integers ReportViewer Question |
|||||||||||||||||||||||