Showing posts with label ie6. Show all posts
Showing posts with label ie6. Show all posts

Monday, March 26, 2012

PageRequestManagerParserError in IE6 and 7

Hi,

I've created a pretty simple custom control that filters items based on categories the user selects in a drop down box.
Here's the error I'mintermittently getting in IE6 and IE7 but not any mozilla-based browsers.

error

Because of it's intermittent nature it seems like something out of my control...
I've made sure there are no Response.Write(), Response Filters, HttpModules running and that server trace isn't enabled.

I've used Fiddler to look at the responses but can't find the offending part in the error message.

I've googled the error and found this:

http://forums.asp.net/p/1037846/1437627.aspx

I am using a VirtualPathProvider to map requests to items in a cms, but the article above deals with an incorrect formaction being returned in the httpmessage. I've checked the formaction being returned and it is correct.

I'm at a loss. This is a real pain because a lot of time has been invested in using Asp.Net Ajax for our new site and this may make us have to rethink that decision.

Here is the code for my custom control.

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Collections;

using System.Collections.Generic;

using System.Text;

namespace Unwrong.Controls

{

publicclassFilterList :Control,INamingContainer

{

privatestring _Category;

privateList<FilterListItem> _Items =newList<FilterListItem>();

privateint _MaxVisibleItems;

privateint _Position = 0;

privatestring _CssClass;publicstring Category

{

get {return _Category; }

set { _Category =value; }

}

publicList<FilterListItem> Items

{

get {return _Items; }set { _Items =value; }

}

publicList<FilterListItem> ItemsInCategory

{

get {return GetItemsInCategory(); }

}

publicint MaxVisibleItems

{

get {return _MaxVisibleItems; }

set { _MaxVisibleItems =value; }

}

publicint Position

{

get {return _Position; }set { _Position =value; }

}

publicstring CssClass

{

get {return _CssClass; }

set { _CssClass =value; }

}

protectedoverridevoid OnInit(EventArgs e)

{

Page.RegisterRequiresControlState(this);base.OnInit(e);

}

protectedoverridevoid AddParsedSubObject(Object obj)

{

if (objis Unwrong.Controls.FilterListItem)

{

Items.Add((Unwrong.Controls.FilterListItem)obj);

}

}

protectedoverridevoid CreateChildControls()

{

System.Collections.IEnumerator myEnumerator = Items.GetEnumerator();

while (myEnumerator.MoveNext())

this.Controls.Add((FilterListItem)myEnumerator.Current);

}

protectedoverrideobject SaveControlState()

{

FilterListViewstate state =newFilterListViewstate();

state.Category = Category;

state.Position = Position;

return state;

}

protectedoverridevoid LoadControlState(object state)

{

if (state !=null)

{

Category = ((FilterListViewstate)state).Category;Position = ((FilterListViewstate)state).Position;

}

}

protectedoverridevoid Render(HtmlTextWriter w)

{

List<FilterListItem> itemsToDisplay = GetDisplayItems();w.Write(@dotnet.itags.org."<script language='javascript' type='text/javascript'>

<!--

function hide(id){

try{

var obj=$get(id);

obj.style.visibility='hidden';

}catch(e){}

}

function show(id){

try{

var obj=$get(id);

obj.style.visibility='visible';

}catch(e){}

}

//-->

</script>

");w.Write("<div class=\"column1\">");

w.Write(GetItemsInColumn(0));

w.Write("</div>");

w.Write("<div class=\"column2\">");

w.Write(GetItemsInColumn(2));

w.Write("</div>");w.Write("<div class=\"column3\">");

w.Write(GetItemsInColumn(4));

w.Write("</div>");

}

privatestring GetItemsInColumn(int index)

{

List<FilterListItem> items = GetDisplayItems();

// Check if any items are at the necessary indeces.

if (items.Count > index)

{

StringBuilder sbHtml =newStringBuilder();

// Create the html for two projects.

for (int i = 0; i < 2; i++)

{

index += i;

if (items.Count > index)

{

FilterListItem item = items[index];

sbHtml.Append("<div class=\"project\" ");

sbHtml.Append("onmouseover=\"this.style.backgroundColor='#E1E1E1'; hide('" + ClientID +"_title" + index +"'); show('" + ClientID +"_details" + index +"');\" ");

sbHtml.Append("onmouseout=\"this.style.backgroundColor='#FAFAFA'; show('" + ClientID +"_title" + index +"'); hide('" + ClientID +"_details" + index +"');\" ");

sbHtml.Append(">");if (!String.IsNullOrEmpty(item.ProjectLink))

{

sbHtml.Append("<a href=\"" + item.ProjectLink +"\"><img src=\"" + item.Image +"\" alt=\"" + item.Title +"\" title=\"" + item.Title +"\" /></a>");

}

elseif (!String.IsNullOrEmpty(item.LiveLink))

{

sbHtml.Append("<a href=\"" + item.LiveLink +"\" target=\"_blank\"><img src=\"" + item.Image +"\" alt=\"" + item.Title +"\" title=\"" + item.Title +"\" /></a>");

}

else

{

sbHtml.Append("<img src=\"" + item.Image +"\" alt=\"" + item.Title +"\" title=\"" + item.Title +"\" />");

}

sbHtml.Append("<div id=\"" + ClientID +"_title" + index +"\" class=\"title\">");

sbHtml.Append(item.Title);

sbHtml.Append("</div>");

sbHtml.Append("<div id=\"" + ClientID +"_details" + index +"\" class=\"details\">");

if (!String.IsNullOrEmpty(item.ProjectLink))

{

sbHtml.Append("<a href=\"" + item.ProjectLink +"\">View Details</a>");

}

else

{

sbHtml.Append("<span class=\"strikethrough\">View Details</span>");

}

if (!String.IsNullOrEmpty(item.LiveLink))

{

sbHtml.Append("<br/><a href=\"" + item.LiveLink +"\" target=\"_blank\">View Live</a>");

}

else

{

sbHtml.Append("<br/><span class=\"strikethrough\">View Live</span>");

}

sbHtml.Append("</div>");sbHtml.Append("</div>");

}

}

return sbHtml.ToString();

}

else

{

returnstring.Empty;

}

}

privateList<FilterListItem> GetItemsInCategory()

{

List<FilterListItem> itemsInCategory =newList<FilterListItem>();

// Remove all items that aren't in current category.

foreach (FilterListItem itemin Items)

{

if (IsItemInCategory(item))

{

itemsInCategory.Add(item);

}

}

return itemsInCategory;

}

privateList<FilterListItem> GetDisplayItems()

{

List<FilterListItem> itemsInCategory = GetItemsInCategory();

List<FilterListItem> itemsToDisplay =newList<FilterListItem>();

int count = MaxVisibleItems;if (Position + MaxVisibleItems > itemsInCategory.Count)

{

count = itemsInCategory.Count - Position;

}

return itemsInCategory.GetRange(Position, count);

}

privatebool IsItemInCategory(FilterListItem item)

{

if (String.IsNullOrEmpty(Category) || Category.ToLower() =="all")

{

returntrue;

}

foreach (string cin item.Categories)

{

if (c.ToLower().Trim() == Category.ToLower().Trim())

{

returntrue;

}

}

returnfalse;

}

}

[Serializable]

publicclassFilterListViewstate

{

publicstring Category;publicint Position;

}

}

Here is the code for page where it is used:

<asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional">

<ContentTemplate>

<tableid="filter-widget-bar"cellpadding="0"cellspacing="0"border="0">

<tr>

<tdclass="col1">

<imgsrc="/assets_new/images/projects.gif"alt="Projects"/>

</td>

<tdclass="col2">

<tableid="filter-widget"cellpadding="0"cellspacing="0"border="0">

<tr>

<td>

<ctrl:ImageButtonID="btnPreviousProject"runat="server"CssClass="previous"ImageUrl="~/assets_new/images/btn_previous.gif"OnClick="btnPreviousProject_Click"BorderWidth="0"AlternateText="Previous"/>

</td>

<td>

<asp:DropDownList

ID="lstFilter"

OnSelectedIndexChanged="lstFilter_OnSelectedIndexChanged"

AutoPostBack="true"

runat="server">

<asp:ListItem>Favourites</asp:ListItem>

<asp:ListItem>All</asp:ListItem>

<asp:ListItem>Games</asp:ListItem>

<asp:ListItem>Websites</asp:ListItem>

<asp:ListItem>Applications</asp:ListItem>

<asp:ListItem>Playthings</asp:ListItem>

<asp:ListItem>Cms</asp:ListItem>

<asp:ListItem>Flash</asp:ListItem>

<asp:ListItem>Html</asp:ListItem>

</asp:DropDownList>

</td>

<td>

<ctrl:ImageButtonID="btnNextProject"runat="server"CssClass="next"ImageUrl="~/assets_new/images/btn_next.gif"OnClick="btnNextProject_Click"BorderWidth="0"AlternateText="Next"/>

</td>

</tr>

</table>

</td>

<tdclass="col3">

</td>

</tr>

</table>

<divid="projects">

<ctrl:FilterListID="lstProjects"runat="server"MaxVisibleItems="6">

<ctrl:FilterListItemrunat="server"Image="repository/uploads/projects/ilovedust.jpg"Title="ILoveDust"ProjectLink="http://www.unwrong.com/projects/ilovedust/"LiveLink="http://www.ilovedust.com">

<ctrl:Categoriesrunat="server">

<ctrl:Categoryrunat="server">Flash</ctrl:Category>

<ctrl:Categoryrunat="server">Cms</ctrl:Category>

<ctrl:Categoryrunat="server">Favourites</ctrl:Category>

<ctrl:Categoryrunat="server">Websites</ctrl:Category>

</ctrl:Categories>

</ctrl:FilterListItem>

<ctrl:FilterListItemrunat="server"Image="repository/uploads/projects/tado.jpg"Title="Tado"ProjectLink="http://www.unwrong.com/projects/tado/"LiveLink="http://www.tado.co.uk">

<ctrl:Categoriesrunat="server">

<ctrl:Categoryrunat="server">Flash</ctrl:Category>

<ctrl:Categoryrunat="server">Favourites</ctrl:Category>

<ctrl:Categoryrunat="server">Websites</ctrl:Category>

</ctrl:Categories>

</ctrl:FilterListItem>

<ctrl:FilterListItemrunat="server"Image="repository/uploads/projects/communicatorworld.jpg"Title="Communicator World"ProjectLink="http://www.unwrong.com/projects/communicator/"LiveLink="http://www.communicatorworld.co.uk">

<ctrl:Categoriesrunat="server">

<ctrl:Categoryrunat="server">Flash</ctrl:Category>

<ctrl:Categoryrunat="server">Cms</ctrl:Category>

<ctrl:Categoryrunat="server">Favourites</ctrl:Category>

<ctrl:Categoryrunat="server">Websites</ctrl:Category>

</ctrl:Categories>

</ctrl:FilterListItem>

</ctrl:FilterList>

</div>

</ContentTemplate>

</asp:UpdatePanel>


Hi,smeeg

This happens when the machineKey used to encrypt/decrypt the viewstate was changed, and more likely this will happen if you keep the page idle for a long time. To avoid this, you need to have a static machineKey.

Check this articlehttp://blog.g9th.com/2007/01/14/unable-to-validate-data-at-systemwebconfigurationmachinekeysectiongetdecodeddata.aspx

Let me know if you need more info.
You can also see this thread for more help:http://forums.asp.net/t/1115331.aspx

Thanks

NOTE:This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

Wednesday, March 21, 2012

Partial postback in IE7 and Firefox but full postback in IE6

I have a peculiar problem with ajax page not working the same way on IE6 (service pack 2) and on IE7 and Firefox…

IE7 and Firefox works perfectly and I have no complains but whenever I tried to run the page from other computers on the network (with IE6.0) the edit controls and listboxes blink when there is a partial postback which led me to suspect that maybe there is a problem with the java script and full postback is being performed.

I have not posted the code for the page because it's rather generic. I have Tab Control from ajaxtoolkit on the top of the page that switches panes with various edit boxes and list boxes and other common controls. And there is also a timer control within the update panel that triggers updates once a while (10s).

One last thing to note is that I have a listbox tool tip feature done in javascript that is also not displaying right or should I say at all except for some weird stuff sort of showing on the screen - a white outline of sorts of the tooltip. And this is all for IE6.0. Firefox is also not displaying the tooltip but that's not conerns the project since it is directed to work under IE.

Like I said IE7 (and somewhat Firefox) work perfectly…

Any help is appreciated.

Thanks,

Arek

I guess you're just experiencing typical IE6 flickering. If you have "Check for newer versions of stored pages" set to "every visit" you should set it to something else. The problem may still be there though.

Partial rendering and #id css selectors problem

I noticed that if use partial rendering, IE6.0 removes styling information that was applied for an element via #id-of-element css selector. Is there a workaround? I know there are plenty of ways to apply a style to an element, but this one is pretty useful. I'm working with April CTP of Atlas.

Thanks

This bug affects FireFox as well. I've opened a bug report on the feedback center:
http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=b2a2bbe9-9312-4f63-adae-2e77e056ca06