Tag: Localization

Invalid postback or callback argument…

I started getting this error message:

Invalid postback or callback argument. Event validation is enabled using in configuration or in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

I am once again working on my ASP.NET Dynamic Data Entities web application (updated to ASP.NET 4.5 and Unity 3 beta), and after adding localization and applying the MVP pattern to the page and field templates, the above error started occurring. Now, I Bing’ed it, but none of the suggestions I came across did anything to alleviate the problem. I had the issue with the ListDetails.aspx Dynamic Data page template every time I used the pager associated with the GridView control, and I begun by looking at the recent application of the MVP pattern, but that didn’t get me any closer to a solution. I then started looking at how I localized the page template and much to my surprise it was caused by disabling viewstate (ViewStateMode="Disabled") for the UpdatePanel control, in which the GridView was contained.

The solution was to enable viewstate (removing the attribute ViewStateMode="Disabled") for the UpdatePanel control and applying it to the QueryExtender control associated with the GridView, as well as all of the controls in the div element with a class of DD.

UPDATE (March 30th, 2013):

Turns out this causes too much hassle with view state turned off, so I have turned it back on, and added a Response.Redirect in the event handlers for changing languages. It’s an extra roundtrip, but it is so much more elegant, especially seen form the users perspective.

Advertisements

Visual Studio 2012 Beta – Generate Local Resource error

When using the Generate Local Resource functionality (available from the Tools menu) in Visual Studio 11 Beta, it only works for a single Web Form. For subsequent Web Forms, the menu item is grayed out in Design mode and missing in Source mode. This seems to be a Beta error, as you can close and reopen Visual Studio 11, and regain the functionality. A little trivial, but it works. 🙂

ASP.NET Dynamic Data 4 – UI Table Localization

In my previous post I showed how simple it is to localize the field names in the Data Model, mainly for use with Dynamic Data in ASP.NET 4. This is done using the DisplayAttribute, but unfortunately it doesn’t work for objects of type Class, only Properties which relate to the fields or columns of the table or entity. So, I was looking for a quick-fix and having looked at Dynamic Data Preview 4, I decided to derive the MetaModel and MetaTable classes (both found in the System.Web.DynamicData namespace), like this: Continue reading “ASP.NET Dynamic Data 4 – UI Table Localization”

ASP.NET Dynamic Data 4 – UI Field Localization

In Dynamic Data for the .NET Framework 3.5 SP1, you manually had to localize the data fields at time of display, leading to some very hard-to-maintain code. This has all changed in Dynamic Data 4, or rather with the new System.ComponentModel.DataAnnotations.DisplayAttribute class, http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayattribute_properties(VS.100).aspx, which can be used with Silverlight 3 and the .NET Framework 4. In particular, it can be used with your data model, LINQ to SQL or Entity Data Model (ADO.NET Entity Framework) to annotate your fields in a metadata class:

Visual Basic

<ScaffoldTable(True)>
Public Class Brand_Metadata

    Public Property Name As Object
End Class

Partial Public Class Brand
End Class

Continue reading “ASP.NET Dynamic Data 4 – UI Field Localization”