asp.net ajax button fires non-ajax validator - asp.net

I have an ASP.NET webpage with several updatepanels. I have a row of buttons (inside an updatepanel) which are connected to another updatepanel by async triggers.
Further down the page, outside any updatepanels, I have a filefield control with a few validators associated. The filefield works well, but when I call one of the buttons inside the updatepanel mentioned previously, it fires the validators associated with the filefield.
Is this supposed to happen? I thought that the asyncronious triggers only made a partial postback with respect to only the contents inside updatepanels.
Kind regards, Casper

go to each button in the update panel, and change its corresponding property CausesValidation to False

Related

AJAX Add a dynamic form and AJAX Post data

This is what I'm trying to do with AJAX:
[DropDownList]
I have a DropDownList (not inside an UpdatePanel), populated by different Products to "Add" to the database.
[UpdatePanel #1]
Below, I have an Conditional UpdatePanel that listens for "SelectedIndexChanged" on the DropDownList, when that event is triggered it adds TextBoxes to a div "productForm" inside the UpdatePanel. It creates the Form according to the Product to add.
[Button]
Below the UpdatePanel I have a button that "should" submit the form above.
[UpdatePanel #2]
I have an update panel that listens for the event on Button "Click" event. I also have a div in the ContentTemplate that should post out data that was submitted from the "Add Product Form" in the first UpdatePanel.
The thing is, when I submit (and the Controls are still visible in the first UpdatePanel. It can't read the data from the TextBoxes becaus they aren't there. Also, if I try to add all this to the same UpdatePanel, the Controls disappear whenever I click the Submit button.
Any ideas how to make something similar work?
Without the code I can suspect that when you dynamically populate first div on dropdown selected index changed event, since its within update panel, viewstate is never made aware of new controls and on submit can't post them back to server.
I've had some bad experiences with update panel and never use it other than very simple scenarios. Try getting familiar with jQuery ajax. I would do what you want to do using jQuery and web methods.

Visible Property of ASP.Net Control not working

I have a radiobutton list and three placeholders in my page, out of which the radiobutton list,first and third placeholder are within updatepanel, second placeholder is not within updatepanel.
When radiobutton list selectionindex is changed, I want all three placeholders invisible. Placeholder2.visible=false code executes but still Placeholder2 is visible.
How to resolve this.
Thanks,
Viknesh.A
You should put all your placeholders in update panel on reload the page when the radio button hits (full post back) by setting AutoPostBack="true"
You should understand that by default changin radio button on a client only affects client html, so you need to pass that info to server.
Another option is to have client onclick for radiobutton and write your custom javascript function to hide your second placeholder, but don't forget to manage that situation on the server as well, when postback (either ajax or not) will occur.
Move Placeholder2 inside the UpdatePanel.
Or don't use an UpdatePanel at all.
Or use JavaScript to hide it, instead of server-side code.

Button, UpdatePanel and MasterPage

I have asp.net application and a TabContainer from AjaxControlToolkit on a form. There are 4 tabs, each containing UpdatePanel, hidden button and some custom .ascx (each with it's own javascript file). Buttons are triggers for panels to update the contents and they are triggered from the 'OnClientActiveTabChanged' event of the TabContainer.
This technique is described here and similiar here. It's pretty simple when looking at it.
The only problem I have is that the whole scenario works when used as a separate page but it doesn't seem to work when masterpage is around that page. Suddenly buttons act as full postback controls.
Do you have any idea what's the reason?
Assuming the buttons your referring to are on the master page, I think you'll want to register the master page buttons as update panel triggers.
http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-updatepanel-triggers

Update parent updatepanel from within usercontrol

I have an update panel that contains a repeater that calls a user control into each row. When I click a button inside the user control, the page does not refresh at all, only when I reload it completely. How can I make the update panel refresh from user control's button click?
Phairoh is correct that your button needs to successfully cause a PostBack.
There are three things that affect when a UpdatePanel is updated:
The UpdateMode property - This takes two possible values, Always and Conditional.
If it is set to Always then any postback o the page will cause the UpdatePanel to update.
If it is set to Conditional then the UpdatePanel is only updated when the UpdatePanel's Update method is called or when one of the UpdatePanel's triggers does a postback.
The Triggers proroperty - Defines which controls will cause the UpdatePanel to be updated when UpdateMode is set to Conditional.
The ChildrenAsTriggers property - This is a boolean value that determines if child controls of the UpdatePanel are automatically considered triggers without having to be added to the Triggers collection.
Because your button is in a UserControl it won't be easy to add the control to the Triggers collection or to have the button call the Update method on the UpdatePanel that is not inside the UserControl.
Because your UpdatePanel contains the UserControl's your best bet is to enable ChildrenAsTriggers. If this doesn't work try setting the UpdateMode property to Always. If this still doesn't work then Phairoh is probably correct and your Button isn't posting back.
Sometimes solving this problem not really convenient with Triggers. So here is another fancy approach which could be used even from your user controls without any knowledge about Update Panel:
var scriptManager = ScriptManager.GetCurrent(Page);
if (scriptManager != null)
scriptManager.RegisterPostBackControl(SomeControlID);
Are you sure your buttons on your user control are attempting to do a postback? I haven't used update panels in a while (and I'd actually recommend avoiding them) but if I recall correctly they will refresh whenever a postback is done within them. This means that your buttons must be Asp:Buttons (or similar controls that cause postback) and not have some kind of javascript on them that would not allow their action to continue (such as a return false).

GridView.PageIndexChanging fires but there's no SelectedIndex afected!

I have tow diferent implementations for the same problem.
A gridview that is binded with some data and it has a select column that has a button. When the button click is fired I know in debug that the : sender.SelectedDataKey and sender.SelectedIndex have values that I use later.
But now I whant to use the ajax accordion control. I have an Accordion, and one Pane inside. Inside that pane I have a CollapsiblePanel (that uses the CollapsiblePanelExtender). And in that CollapsiblePanel I have my Gridview.
So, only when I click on the collapsiblePanel I want to get data from DB and bind it to the GridView. But it seems that using this methot the sender.SelectedDataKey and sender.SelectedIndex are Nothing (VB) when the PageIndexChanging fires!
This does not make any sense!
The GridView is the some on both implementations and EnableViewState=true
Thank you.
With the Accordion Panel being an Ajax control, it might be adding the Update Panel in there even though you did not add one to the page. Since the GridView is inside of an Ajax control, all the events that are being triggered by the GridView are going to be captured by Ajax. You might try making the GridView button clicks an Ajax callback as well.
I have run into this problem before where the controls inside of an Ajax Update Panel or an Ajax control; such as the Accordion Panel, fire the server side event handler, but because Ajax is involved, the values were stuck back on the client side.
be sure that your controls are in the same UpdatePanel, or update the various container UpdatePanels.

Resources