I have a UserControl which contains voting buttons inside an UpdatePanel, and outside a Repeater, it works perfectly. In the repeater, clicking the button fires off the appropriate event. That event is supposed to update the text of a control within the User Control, and that update should be reflected when the UpdatePanel refreshes.
If tried the UpdatePanel in UpdateMode Always and Conditional (firing the Update event after making the changes to the properties in the _Click method, and the same problem happens both ways.
Is there something about how UpdatePanels behave in Repeaters that I'm missing?
Thanks.
The reason might have nothing to do with the update panel, but with the postback loosing track of your UserControl. Possibly assigning unique IDs to your user controls may help.
Your repeater is building a table correct? The problem is most likely that an update panel generates a div tag and it's probably outside any TR and TD tags so the browser doesn't know what to do with it.
http://www.netortech.com/blog/?articleid=8
Related
I have a webforms page with 2 UpdatePanels: udpGrid for a gridview and udpFormViews with a ajaxToolkit:TabContainer surrounding 3 tabs for Insert and Editing records from the grid, and a repeater with it's own item template for editing related data to the main record. The edit tab is invisible on Page_Load. Inside the insert and edit tab resides the same Usercontrol which contains a Formview. the formview is set to insert mode by default but has an insert and edit item template with a footer template for save/update/cancel buttons, and when editing The second instance of the usercontrol gets set to edit mode and loaded and shown. It also contains a footer template containing the insert udpate and cancel commandbuttons to trigger the FormView's native inserting/updating/cancel events. RequiredField valdators on the insert FormView UserControl works fine from start and after inserting, but as soon as i do a postback to show the edit FormView usercontrol or the Repeater on hte 3rd tab (which has no relation to the Usercontrol containing the UserControl) the RequiredFieldValidators on the insert formview stop working at all, and even in code validating it's insert-validationgroup returns valid while the requiredField shows empty text in code.
For some reason the insert FormView UserControl loses it's validation logic completely after any postback but it's own Insert, with or without the second instance of the UserControl present. I don't load or change anything to the insert Formview UserControl and i can keep inserting without breaking the Validation but whenever a postback occurs outside of it it breaks. Even updates on the other UpdatePanel (udpGrid) break it and i have no way to test validation on the insert UserControl clientside or serverside using the RequiredFieldValidators. The Edit UserControl does still fire its validators but besides showing the error text on screen it ignores it and still updates the record, also ignoring server side the edit-validationgroup validation.
Does anyone know what is happening? it seems putting these Formvies in UserControls kind of breaks things while using it plain on other pages causes no issues?
Update: i found out that when the RequiredFieldValidation is broken i can still trigger the errortext by filling and emptying the textbox on the clientside. the problem that the page validation on client side and on server side doesnt work correctly persists
Found out the problem after some extensive digging. I was using ASP:Linkbuttons inside the footer template which didn't do the validation anymore after the UpdatePanel surrouning everything did an update. Even though i used ChildrenAsTriggers="False" on my UpdatePanels it somehow messed up the clientside validation triggers.
I went and moved the buttons into the templates themselves and changed them into ASP:Buttons. I believe i needed the buttons to be Linkbuttons since the normal Buttons wouldn't trigger postbacks with the FormView_ItemUpdating and FormView_ItemInserting events of the Formview in the Footer template, but now that i have dedicated buttons inside the Insert and Edit templates they can be normal Buttons again.
Hope this helps someone out there facing a simular problems.
The code is a little big to post here, but hopefully someone can give me some ideas on what to look for.
I've got an ASP.NET Webforms page, containing a Bootstrap Modal dialog box. Inside this modal I have some runat="server" controls, including a Repeater. I have 2 LinkButton controls, one inside the Repeater and one outside, both of which are bound to the same server-side event handler.
The link outside the Repeater works correctly. The one inside still posts-back, but does not fire the event as expected.
Some things I noticed:
My first thought was that the modal was being removed from the
ASP.NET form (as some are prone to do), but if this was true, none
of the controls inside would work.
I tried this using regular Buttons, and it worked correctly. That
means it's something to do with the __doPostBack Javascript that
LinkButtons use.
Any ideas?
If I understand you correctly, are you say that LinkButton in Repeater cause full post-back?
are you try to set ClientIDMode="AutoID" for repeater?
What do you mean "but does not fire the event as expected"
I have an UpdatePanel that contains a repeater that basically builds a list of checkboxes. Those check boxes are set to AutoPostback with an "OnCheckedChanged" event.
When the user checks a checkbox, everything happens as expected except for one thing, the page pops (or scrolls) back to the top.
Other controls that cause this UpdatePanel to refresh don't cause this issue, even just plain checkboxes that ARE NOT inside of my repeater, but still within the UpdatePAnel, work fine (no scroll back to top)...
Any ideas?
open your page in designview (Source) at the top you will find pagedirectives
try adding MaintainScrollPositionOnPostback="true"
hope it helps !!!
I have a custom control that has an update panel in it. Within the update panel, there are no custom controls, but there are custom controls outside the update panel. All controls have an ID set as do the parents of the controls. Inside the update panel is a repeater that has controls that should trigger an async postback. The update panel has an update mode of conditional and children as triggers is off. The update panel renders standalone divs, not table cells. EnablePartialRendering is on on the script manager.
Each repeater item has numerous textboxes, but two of them have autopostback turned on. Inside the repeater ItemDataBound event, I register the control with the script manager's RegisterAsyncPostBackControl.
If I edit either textbox, it does a callback correctly. But after the first one is edited, if you edit the other one, it does a full postback. It doesn't matter which one is done first. But after it's done its postback, if you edit either of the textboxes, it does callbacks correctly.
I've tried several things like changing the UpdateMode and ChildrenAsTriggers properties to various combinations. Nothing seems to work.
Any suggestions?
A lot of things can cause this, compare UpdatePanel causes full page postback with LinkButton in ListView in UpdatePanel causes full postback.
You'll need to provide more information, e.g. .NET Framework version, IIS version etc. exact ASP.NET markup etc
But since you asked for "Any suggestions?" try looking through these questions
I am trying to access the Text property of a textbox from a partial postback-done in an Update Panel. The problem is that this textbox I want to access is not in this Update Panel, and when I am trying to write to it (putting content in the Text property), this new content is not being displayed.
I think that this is because this textbox is not part of the Update Panel's, but I'm not sure about it. And also, I cannot put this Textbox in the same update panel as the one I'm triggering a partial postback.
Why isn't the text being displayed?
During a partial page rending only controls contained within an update panel will have thier html refreshed. The rest of the page will remain the same.
For your specific case you would need to wrap your text box in an update panel, then you hnave a decision to make. You can either mark its UpdateMode as Always or Conditional. If you mark it as always then all the controls contained within that update panel will get updated durning every partial rendering. If you mark it conditional then you will need to call the update panels Update() method to have it's html refreshed.
I don't think you can, unless you put the text box in a second update panel with the update mode set to Conditional. Then you invoke the update method or set the first update panel as an asyncpostbacktrigger to the new one.
What you are trying to do cannot be done unless you put the textbox in question inside another update panel.And if you want to use the contents of your textbox under other events then set the updatemode for the new updatepanel to always. But if you want to access its Text property only during the event which is the trigger for your other update panel then set the updatemode to conditional and also set the triggers of both the panels as same...
If you are not sure about triggers and updatemode (basically how it works) then just set updatemode to always in both updatepanels and forget about the triggers.
It will work fine then...