Listbox not causing post back in Chrome and Safari - asp.net

In chrome and safari I am having problems with a list box I have. The data is loaded on the backend initially which works fine. But then on the event SelectedIndexChange I want to figure out what they selected and update my panel with that info. Problem is chrome and safari is not calling the event. Ive checked for script erros and get none. IE and FF work just fine, so I am just wondering what is wrong with those browsers and what I can do to fix this. Basically this is a control that sits inside a sharepoint 2007 page.
<asp:UpdatePanel ID="ISudpl" runat="server">
<ContentTemplate>
<strong>Product</strong><br /><asp:ListBox runat="server" ID="Product"
OnSelectedIndexChanged="Filter_SelectedIndexChanged" EnableViewState="true" AutoPostBack="true"
SelectionMode="Multiple" Rows="15" CssClass="designIntent"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Product" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>

I think this is a documented issue with Microsoft AJAX and webkit based browsers check here http://blog.turlov.com/2009/01/aspnet-ajax-compatibility-patch-for.html and here Asp.Net, DropDownList, AutoPostBack and Google Chrome for a possible solution

You do not need Trigger because your control(ListBox) is inside same UpdatePanel. Please remove the complete <Triggers></Triggers> block from your code and check if it works in Chrome?

Related

Dropdown lists don't work correctly with Modal Popup Extenders in newer version of Firefox

I recently updated firefox to the latest version, 40.0.2, and have come across a problem dealing with the AJAX ModalPopupExtender and dropdown lists.
The issue is that when I open a ModalPopupExtender and try to select one of the values from the dropdown list, it does nothing. It keeps the dropdown list open an nothing gets selected. Furthermore, if I click and hold, it allows me to drag the Popup as if I was dragging the header.
My popups are in the following format:
<ajax:ModalPopupExtender id="mpeModal" runat="server" PopupControlId="pnlModal" PopupDragHandleControlID="pnlModalHeader" />
<asp:Panel id="pnlModal" runat="server" CssClass="modal-panel" style="display:none">
<asp:Panel id="pnlModalHeader" runat="server">
<uc:PopupHeader id="phModalHeader" Text="Header Text" runat="server />
</asp:Panel>
<div class="modal-content">
<asp:TextBox id="txtField" runat="server" />
<asp:DropdownList id="ddlField" runat="server />
</div>
</asp:Panel>
The last version of Firefox I was using was 34, so I'm not sure if a version between 34 and 40 would have changed how this works.
Any idea what would cause this issue with Dropdown Lists in AJAX Modal Popups?
After more testing of my app, I found a few cases where it did work correctly.
The issue was that in some cases pnlModalHeader was not present in the markup and PopupDragHandleControlID was set to pnlModal. This is how all the old Modal Popups in the app were being done and in previous version of Firefox (and all other browsers) this caused the user to be able to drag the ModalPopup by clicking anywhere in the panel, not just the header. I changed this, but must have missed a couple.
It now works appropriately in the newer version of Firefox.

Update panel postback on Internet explorer

I have an update panel and inside that I have a repeater and a button.
On button click it filters some data and binds the repeater.
Everything is working fine on local host. On server, everything is working perfectly in chrome, firefox, safari, but in Internet explorer it does a full postback.
I tried with putting button click in
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnupdaetd" />
</Triggers>
But to no effect. Except Internet explorer, on each browser everything is working fine.
I even tried
<meta http-equiv="X-UA-Compatible" content="IE=9" />
with no luck.
Nothing is wrong in code, as everything is working perfectly in chrome, firefox, safari. The only issue is with Internet explorer in server. On local it's working in internet explorer too.
Try changing this
<asp:AsyncPostBackTrigger ControlID="btnupdaetd" />
to
<asp:AsyncPostBackTrigger ControlID="btnupdaetd" EventName="Click" />
and add ClientIDMode to AutoID on your asp button like this
<asp:Button runat="server" ID="btnupdaetd" ClientIDMode="AutoID" Text="Click" OnClick="btnupdaetd_Click" />
also in your update panel add UpdateMode="Conditional" like this
<asp:UpdatePanel ID="upd1" runat="server" UpdateMode="Conditional">

UpdatePanel working only on Chrome and not in IE / Mozilla. Why?

On Clicking the LinkButton, I refresh the image in image control without refreshing the page. For this I have used the UpdatePanel and AsyncPostBackTrigger.
It is working perfectly in chrome. But not in IE and Mozilla. On both IE and Mozilla when I click the link button, nothing happens. Look very weird. Have any clue on this ?
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="txtCaptchaInput" BorderStyle="Solid" Style="vertical-align: top" runat="server" Width="106px" BorderWidth="1px"></asp:TextBox>
<asp:Image ID="img_captcha" runat="server" Height="32px" ImageUrl="~/captchaJPEG.aspx" Width="108px" />
<asp:LinkButton ID="captcha_refresh" runat="server">Refresh Image</asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="captcha_refresh" />
</Triggers>
</asp:UpdatePanel>
CaptchaJPEG.aspx : Page Load
Dim captcha As New Captcha.CaptchaImage()
captcha.width = 150
captcha.height = 40
captcha.text = Me.Session("CaptchaText").ToString()
captcha.GenerateImage()
captcha.image.Save(Me.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
Your issue have to do with the caching of the captchaJPEG.aspx that return an image. As image the browser can keep it and not change it.
To avoid that you have two ways, you can set some cache headers to say to the browser to not keep it on the cache as:
Response.Cache.SetExpires(DateTime.Now.AddDays(-10));
Response.Cache.SetMaxAge(new TimeSpan(-10, 0, 0));
Or -that I think is better- add a random number on the image tag as you set it on code behind, as:
img_captcha.ImageUrl = "~/captchaJPEG.aspx?_rnd=" + RandomNumber;
Here you can make something even better, to use the hash() of your code captcha, as:
img_captcha.ImageUrl = "~/captchaJPEG.aspx?_rnd=" + CaptachHiddenNumbers.hash();
Thats way you keep it on cache if the captcha is the same from load to load.
Now, the "correct way" is to use a handler and not a page for many reasons, like you do not want all the overhead of the page just to send an image. Now the handler come with the minimum modules call, to add session you need to use the IRequiresSessionState.
To answer to the question, why is acting different on the browsers, is because in some small details browser have different behavior, is depend how and what they check to make a decision to use the cached images and how aggressive are the browser with the cache.

Drop Down List (in Update Panel) causing FULL PostBack!

I have a problem with my AJAX and ASP.NET 3.5 :(
Problem is really weird, as I'm using the same thing on different page and it works fine in there, but on this specific page, this is not working.
Here's what I have:
<asp:UpdatePanel ID="upMain" runat="server" UpdateMode="Conditional" Visible="true" RenderMode="Inline">
<ContentTemplate>
<asp:DropDownList ID="ddlNewService_PortTelco" runat="server" Width="250" CssClass="dropdown" AutoPostBack="true" OnSelectedIndexChanged="Provision_PortedTelcoChanged"></asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
On the way before the DropDown there is one DIV (html one), and then few asp:Panels.
I do not understand why this is causing a FULL POST BACK ?!
Any ideas ? Thanks
i had the same problem... altho it's not showing in the copied code here, check to make sure you don't have any controls with ClientIDMode=Static within the updatepanel .... make them inherit
at least any controls that may trigger a postback
Me having the same problem...
CHECK your WEB.CONFIG
<xhtmlConformance mode="Legacy"/>
for this line.. and JUST REMOVE IT!!
Worked for me. Thanks http://andrew-murphy.co.uk/?p=152
You have your drop down list with an AutoPostBack set to true. That's why you have it post back instead of AsyncPostBack, if that is what you wanted.
Remove the AutoPostBack=true from the dropdownlist
and set an Async trigger for your UpdatePanel set to the dropdownlist and its eventname="SelectedIndexChanged"
Excuse my lack of programing skills :| It all worked all the time, but because one of the actions page "looked" like it's POST BACKED, when it wasn't. What a shame!!!
Sorry for waisting Your time!
Setting the AutoPostBack attribute to true should be enough to cause a partial postback but it's not what happens and a full postback is triggered instead as you correctly described.
The following workaround works for me:
Drop the AutoPostBack attribute.
Trigger the postback using the "onchange" client side event.
This is how the original DropDownList should look like:
<asp:DropDownList ID="ddlNewService_PortTelco" runat="server" Width="250" CssClass="dropdown" OnChange="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(this.name, '', true, '', '', false, true))" OnSelectedIndexChanged="Provision_PortedTelcoChanged"></asp:DropDownList>
For more details regarding the WebForm_PostBackOptions parameters see below:
function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit)
http://msdn.microsoft.com/en-us/library/system.web.ui.postbackoptions_members(v=VS.90).aspx
If you have some asp component with Autopostback="true" and ClientIdMode="Static", you have to use the trigger.
Like this:
<asp:UpdatePanel ID="upPrinceOffuce" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlPrintOffice" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:DropDownList ID="ddlPrintOffice" runat="server" ClientIDMode="Static" AutoPostBack="true" ...blah blah
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
How do you bind your DropDown? The code that you have provided works on my side with static items. Perhaps it is something in the other controls that is causing the problem.
I have noticed that your UpdatePanel has its UpdateMode property set to conditional, however you haven't defined any triggers.You can try to explicitly set that the update panel should perform async postback when your dropdown triggers its selectedIndexChanged event. You can use something like the following markup:
<asp:UpdatePanel ID="upMain" runat="server" UpdateMode="Conditional" Visible="true"
RenderMode="Inline">
<ContentTemplate>
<asp:DropDownList ID="ddlNewService_PortTelco" runat="server" Width="250"
AutoPostBack="true" OnSelectedIndexChanged="Provision_PortedTelcoChanged">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlNewService_PortTelco" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
Set AutoID value to ClientIDMode property. It worked for me. I have had different behaviour in different browsers (i.e. Google chrome and Firefox).
Had the same problem when the Dropdownlist Autopostback attribute was set to true
and fixed the problem by adding the dropdownlist ID to the updatepanel trigger
I had this problem. My Dropdownlist was inside of an HTML table and I had my Update Panel wrapped around two individual rows. I fixed the problem by wrapping the Update Panel around the entire table rather than just the two rows.
One alternative to fix this issue is:
Declare the library
using AjaxControlToolkit;
Then you can do something on these lines
private void InitControl()
{
//FIX - DROP DOWN
ToolkitScriptManager scrManager = (ToolkitScriptManager)Page.Master.Controls[0].Controls[0].FindControl("manScript");
scrManager.RegisterAsyncPostBackControl(ddlNewService_PortTelco);
}

Firefox and Updatepanel

I have a problem with FireFox and ASP.NET UpdatePanel.
I have in a form a checkbox and an UpdatePanel. When I check the checkbox, an asp:panel which is into the UpdatePanel should become visible.
<asp:CheckBox ID="cbMoreOptions" runat="server" Text="plus d'options" AutoPostBack="True" OnCheckedChanged="cbOptions_CheckedChanged" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" Visible="false">
sssssssss
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cbMoreOptions" EventName="CheckedChanged" />
</Triggers>
</asp:UpdatePanel>
Everything is working fine but not after I refresh the page while the checkbox is checked. If this is happening, the checkbox rest checked the page doesn’t make postback more to the server. The firebug shows that the page gets a response and when I verify the its content I have en error 500 which tell that the information of the page is corrupt. All this is happening only in Firefox. In IE8 and Google Chrome everything is ok.
Does anybody have an idea how can I avoid this? It’s a bug of Firefox?
All the weird comportment continues until I make enter into the URL textbox. Even if I make F5 nothing happens. What is the difference between F5 and enter into the URL? They shouldn’t have the same result?
Thanks a lot.
Have you tried placing the checkbox "cbMoreOptions" inside the UpdatePanel?
Place in inside the UpdatePanel ContentTemplate section and set an AsyncPostBackTrigger for the CheckBox.
We had this problem a long time ago and it was the way firefox uses in-memory cache to store the state of a page which messes up the way ASP.NET handles VIEWSTATE hidden field. Check if caching turned on for your aspx pages and disable it.
Edit: Here's a link that explains it in detail.
What is the difference between F5 and enter into the URL? They
shouldn’t have the same result?
If you hit enter in the address bar, it does a GET request, i.e. you enter your page's lifecycle with !IsPostBack.
When you hit F5, I observed that firefox will repeat the last request, so if that last request was a POST, it will repeat it. That's why your page stay in a buggy state. If the first post back caused an error (the checkbox' checkedChanged), hitting F5 will just repeat that error.
So, no, the don't have the same result.
I don't have any documentation to backup this statement, but this is what I observed. If anyone can point a source I'll be glad to see it.

Resources