Clicking on linkbutton, don't want validators to fire - asp.net

I have a profile page with a bunch of textboxes and validators. The validation works fine right now. My issue is that I have added a couple of link buttons that go to different pages. When I click on a linkbutton the validators fire, which I don't want. I just want to go to the next page.
I tried disbling the validators in the linkbutton click event but it didn't work. How do I stop the validators firing?
Thanks

Simply set the CausesValidation atrribute to false on the linkbuttons in the markup:
CausesValidation="false"
LinkButton.CausesValidation Property

Related

Disable/Enable a button inside a panel on an ascx control in a vb.net website from codebehind not JQuery

In my website I have a vb.net ascx control which contains a number of textboxes and a button. When the button is clicked I want to disable it, then perform some actions using the values of the textboxes, and then enable the button again. The problem i'm having is that i cannot disable the button.
The ascx control contains an asp:Panel, and inside that is an asp:UpdatePanel which contains the textboxes and the button. Could the asp:Panel or the asp:UpdatePanel be preventing the button being disabled? I can empty the textboxes without a problem, but nothing seems to work on the button.
I've tried
btnButton.Enabled = False
and
btnButton.Attributes.Add("disabled")
but they have no effect. Neither does setting the Visible property to false. The UpdateMode on the Asp:UpdatePanel is set to Always. I'm not too familiar with Asp:Panels or Asp:UpdatePanels so i'm guessing it's something to do with them. Does anyone know the correct way to do this?
After some more research I came across the solution. I just needed to add some attributes to my button like this:
<asp:Button ... OnClientClick="this.disabled=true;" UseSubmitBehavior="false" />
This will disable the button when it is clicked, but still allows the codebehind to run as well. When the codebehind has completed the button will be enabled again.

__doPostBack won't work if JavaScript is disabled

If the JavaScript of browser is disabled then __dopostback won't work. I am looking for the alternative to this because I have radio button and drop down list controls in web page that should fire postback even if JS is disabled.
Autopostback cannot be made to work without javascript, as a workaround, you could put a button next to the radio button/drop down list only for those users with javascript disabled to manually trigger a post back:
<noscript><asp:Button ID="uxManualPostback" runat="server" Text="Go" /></noscript>
In the code behind (server side) you would then hook up the button's click event to do same thing the autopostback of the radio button/drop down list would have done.

Show asp.net UpdateProgress control on submit only

I have a page with 2 buttons on.
I want to show the updateprogress only when the page is submitted via one of the buttons, but not the other cancel button. I've been struggling for a while to come up with a solution.
Anyone know how I can do this?
Add parameter AssociatedUpdatePanelID for UpdateProgress, and set AsyncPostBackTrigger for UpdatePanel to button you want to make a postback.
If above instructions doesn't help, you can also try to wrap controls you need into asp:Panel control and set DefaultButton to your Submit button ID.

Problem with Ajax control toolikt Modal Pop control

I have an ajax control toolkit modal popup on my page and in that modal popup i have a gridview on which user select some item through checkbox on each row of gridview. Whenever user check or uncheck on checkbox my modal popup automatically hide. I have set autopost property of checkbox set to true becuase im perporfing some calculation on each checkchanged event. what may be the problem
Your page is posting back because of the autopostback="true" on the checkbox, thus hiding the modal popup.
Look up 'ASP.Net Page Lifecycle' for further understandinf. It is important to know how this works.
I'm sure you'd also like to know how to solve this.
You could:
Set AutoWireUp=false on the page, but then you'd have to wire all events on the page manually. Since you aren't familiar with the Page Lifecycle, I'm not sure how successful you'd be.
Use a javascript-only modal popup.
Perhaps an UpdatePanel can be used.

ASP.net Modal Pop up extender and DropDownlist autopostback

I have a GridView control where if the user click on the auto-generated edit button. A window will pop up using modal pop-up extender with a drop down list for user to select. The problem is the SelectedIndexChanged event will not fire if AutoPostBack is set to false.
But if I set the AutoPostBack to true the pop-up will go away without firing the SelectedIndexChanged event.
Is it possible to have a control with AutoPostBack set to true inside the modal pop-up?
Please put below code on drop down server side change event
modalpopup.show();
updatepanel.update();
where modalpopup is "ID" of modalpopupextender
and updatepanel is "ID" of updatepanel
The problem is the selectedindexchange
event will not fire if autopostback is
set to false...
I'm not sure that statement is strictly true. Isn't it a case that if autopostback is false, the SelectedIndexChange event fires during the next postback? So if you change the index, then click a Submit button, that's when the index change event is fired.
This isn't much good if you need server code to run to respond to the index change while the popup is still showing, but otherwise, you can still respond to the index change.
If you need to change something in the popup in response to the index change, you can always use client-side javascript.
You can use an UpdatePanel to resolve this problem. Wrap the DropDownList and any other controls that might give similar issue inside of an UpdatePanel, inside of the pop-up control. This will allow the pop-up to continue showing, while executing your postback code at the right time.

Resources