having an issue supporting IE6 (meh)..
I have an update panel that is triggered by radio buttons. Its pretty straightforward.. show a form if one button it clicked, or another form if another button is clicked. In IE 7, 8, Firefox, etc. this works fine.
In IE6, the radiobutton selection doesnt update the form. If I make a selection, then click the submit button, when the page reloads it will be in it's desired state (meaning the correct form will show). So it's almost like the AutoPostback isnt firing to update the page.
Has anyone encountered this issue? Thanks In Advance..
Here's a shortened sample of what Im running into:
<asp:UpdatePanel ID="updrdoBuyingFor" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rdoBuyingFor" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:RadioButtonList ID="rdoBuyingFor" runat="server" AutoPostBack="true" >
<asp:ListItem Text="I am buying for someone else" Value="1" />
<asp:ListItem Text="It's for me" Value="2" />
</asp:RadioButtonList>
</ContentTemplate>
<asp:UpdatePanel ID="updMyInfo" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlMyInfo_Country" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="imgBtnContinue" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="rdoBuyingFor" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
...Code for Form A...
</ContentTemplate>
<asp:UpdatePanel ID="updFriendsInfo" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlMyInfo_Country" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="imgBtnContinue" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="rdoBuyingFor" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
...Code for Form B...
</ContentTemplate>
In response to #Pabuc below, Im setting the visible property of the table in "Code for Form A\B" to true or false depending on the radio button selection.
I've had the same problem with combobox.
What I did was instead of making the combobox visible, invisible, I made the tablerow visible invisible. I'm sure it'll work for you too. If you have more than 1 cells in your row, make the cell visible/invisible.
Let me know if it works.
Attributing this issue to the same question\answer I posted here: asp net 4 - autopostback doesnt fire in ie6
Related
I want my templated buttons to have an update panel around it, but it messes up my rowindex attribute for the control. I tried to get the parent of the container but it says displayindex is not a property
<ItemTemplate>
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="IBRemove" EventName="click" />
</Triggers>
<ContentTemplate>
<asp:ImageButton ID="IBRemove" runat="server" RowIndex="<%# Contanier.Parent.Displayindex %>" OnClick="IBRemove_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
The Link that VDWWD commented worked fine and it makes more sense to wrap the entire gridview in the update panel.
I was looking for this though:
RowIndex="<%# (DirectCast(Container, IDataItemContainer)).DisplayIndex %>"
Consider the following code fragment:
<div>
<asp:Button runat="server" ID="trickyUPTrigger" Text="Tricky Update" />
<div>
<asp:Button runat="server" ID="normalUPTrigger" OnClick="normalUPTrigger_Click" Text="Normal Update" />
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="normalUPTrigger" />
</Triggers>
<ContentTemplate>
<asp:Label runat="server" ID="changeableLabel" Text="Change me"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
Now make the button with ID of trickyUPTrigger as the trigger of the UpdatePanel. Or, devise a mechanism (probably... using javascript?) so that when this button is clicked UpdatePanel updates without full page postback.
If you want to update the UpdatePanel when clicking on trickyUPTrigger, you can add that button to the triggers list:
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="normalUPTrigger" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="trickyUPTrigger" EventName="Click" />
</Triggers>
<ContentTemplate>
...
</ContentTemplate>
</asp:UpdatePanel>
UPDATE
You asked some code examples showing cases with naming containers, a concept that comes into play for databound controls with item templates, like the GridView and the ListView, and for user controls. In the examples below, I use a ListView, where each item is a separate naming container.
If you wanted to trigger an update of your panel from a button in a ListView item template, the trigger would not be found at runtime, and an exception would occur:
<asp:ListView ID="lstView" runat="server">
<ItemTemplate>
<asp:Button ID="anotherTrigger" runat="server" Text="This trigger cannot be found!" OnClick="anotherTrigger_Click" />
</ItemTemplate>
</asp:ListView>
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="anotherTrigger" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
The reverse case (the UpdatePanel in the ListView item template, the trigger button outside of the ListView) does work, according to my tests, which seems to contradict the note that you mention in your comment:
<asp:ListView ID="lstView" runat="server">
<ItemTemplate>
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="anotherTrigger" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</ItemTemplate>
</asp:ListView>
<asp:Button ID="anotherTrigger" runat="server" Text="This trigger works!" OnClick="anotherTrigger_Click" />
Finally, the case where the UpdatePanel and the trigger button are both in the ListView item template also works:
<asp:ListView ID="lstView" runat="server">
<ItemTemplate>
<asp:Button ID="anotherTrigger" runat="server" Text="This trigger works!" OnClick="anotherTrigger_Click" />
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="anotherTrigger" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</ItemTemplate>
</asp:ListView>
You can notice that I set UpdateMode="Conditional" for the panel in this last example. With this setting, the panel is updated only by its own triggers. If the attribute is set to UpdateMode="Always", the panel is updated not only by his own triggers but also by the triggers of the other UpdatePanels in the page. The default value is UpdateMode="Always" (as in your code sample).
How i can prevent page refresh when button click without using UpdatePanel in asp.net ?
Thanks in advance,
use OnClientClick="return false;
<asp:button ID="btnAdd" runat="server" text="Button" OnClientClick="return false;" />
I know you said you don't want to use an UpdatePanel, but this might work with your tabs, though I'm not completely sure. From what I've seen, you can create a "dummy" UpdatePanel that just holds your AsyncPostBackTriggers, then match them to your control handlers. I just ran across something like this:
<asp:UpdatePanel ID="upnlAsync" runat="server" >
<ContentTemplate>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSave" EventName ="Click" />
<asp:AsyncPostBackTrigger ControlID="btnSave1" EventName ="Click" />
<asp:AsyncPostBackTrigger ControlID = "btnBackgroundTasks" EventName ="Click" />
<asp:AsyncPostBackTrigger ControlID = "btnReSubmit" EventName ="Click" />
<asp:AsyncPostBackTrigger ControlID = "btnSubmit" EventName ="Click" />
</Triggers>
</asp:UpdatePanel>
It is matched up with button controls, but they are not in an UpdatePanel themselves. When the Click handler is called in the code behind, the subroutine gets called, but the page doesn't refresh. I realize that this isn't really how the triggers are intended to be used, but it seems to work for my situation. Maybe it will work for yours.
I have a page and it has a button and a user control.
I want to refresh the user control without refreshing the page.
I know I cannot do it otherwise so what I did is wrapped my user control inside the Update Panel.
<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />
<asp:Button ID="btnAdd" runat="server" Text="Add name to list" OnClick="btnAdd_Click" /><br /><br />
<asp:UpdatePanel ID="upShowNames" runat="server">
<ContentTemplate>
<uc1:ShowNames ID="ucShowNames" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAdd" />
</Triggers>
</asp:UpdatePanel>
But I still the control won't refresh.
I also tried calling the update panels. The Update() method by changing its UpdateMode to Conditional but that does not work either...
Does anyone know how can I do it?
Please change these 2 things
<asp:UpdatePanel ID="upShowNames" runat="server" UpdateMode="Conditional">
<asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click"/>
You missed the EventName on the postback trigger, once you add that, it should work :-)
I have a page with some UpdatePanels, each one with its own button to update it. Since the update routines can take some time, I thought making them Asynchronous would help loading the page step by step.
But doing so, when I fire programatically the update routine of each panel, I get only the last UpdatePanel updated.
Here is an example of the code, with two UpdatePanels. There is the requirement that the update routine have to be fired on clientside pageLoad function.
Is it a bug or am I missing something in the code?
Thanks =)
<asp:UpdatePanel ID="Panel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="Text1" runat="server" />
<asp:Button ID="Button1" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="Panel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="Text2" runat="server" />
<asp:Button ID="Button2" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
And the client-side code:
function pageLoad()
{
$('#Button1').click();
$('#Button2').click();
}
Here is why:
By default, when a page makes multiple
asynchronous postbacks at the same
time, the postback made most recently
takes precedence.
http://www.asp.net/ajax/documentation/live/tutorials/ExclusiveAsyncPostback.aspx
Here is a solution:
Handling Multiple Asynchronous Postbacks