This is a good candidate for the “Works on My Machine Certification Program”.
I have the following code for a LinkButton…
<cc1:PopupDialog ID="pdFamilyPrompt" runat="server" CloseLink="false" Display="true"> <p>Do you wish to upgrade?</p> <asp:HyperLink ID="hlYes" runat="server" Text="Yes" CssClass="button"></asp:HyperLink> <asp:LinkButton ID="lnkbtnNo" runat="server" Text="No" CssClass="button"></asp:LinkButton> </cc1:PopupDialog>
It uses a custom control that simply adds code before and after the content to format it as a popup dialog. The Yes button is a HyperLink because it executes javascript to hide the dialog and show a different one. The No button is a LinkButton because it needs to PostBack to process this value.
I do not have an onClick event registered with the LinkButton because I simply check if IsPostBack is true. When executed locally, the PostBack works fine and all goes well. When published to our Development server, the No button does nothing when clicked on. I am using the same browser when testing locally versus on the development server.
My initial thought is that perhaps a Validator is preventing the PostBack from firing. I do use a couple of Validators on another section of the page, but they are all assigned to a specific Validation Group which the No LinkButton is not assigned to. However the problem is why it would work locally on not on the development server.
Any ideas?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Check the html that is emitted on production and make sure that it has the __doPostback() and that there are no global methods watching click and canceling the event. Other than that if you think it could be related to validation you could try adding CausesValidation or whatever to false and see if that helps. Otherwise a “works on my machine” error is kind of hard to debug without being present and knowing the configurations of DEV vs PROD.
Method 2
I had a similar problem. I created a form with an updatePanel, in the form were some linkbuttons that would open a modalpopup Ajax extender. They worked fine until I added authentication to the site. After that they didn’t do anything at all.
Reading your solution I found that some of the linkbuttons WERE working, they were the ones that had CausesValidation explicity set (I only put it in for the ones where I would make that true). Adding CausesValidation=”false” to all the other linkbuttons allowed them to work correctly after I was authenticated.
Thanks for your comments everyone, it saved my day!
Method 3
My understanding of ValidationGroup is that a button with no group specified would trigger all validators on the page. Have you tried giving the LinkButton a different ValidationGroup?
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0