Showing posts with label trouble. Show all posts
Showing posts with label trouble. Show all posts

Wednesday, March 28, 2012

Ajax trouble with Localization HttpModule

Hello,

I'm using this HttpModule :

Imports System.WebImports System.Web.SessionStatePublic Class URLLocalizationHttpModuleImplements IHttpModule, IReadOnlySessionStateDim LangueAs String Dim OriginalURLAs String Public Sub Dispose()Implements IHttpModule.DisposeEnd Sub Public Sub Init(ByVal contextAs HttpApplication)Implements IHttpModule.InitAddHandler context.BeginRequest,AddressOf context_BeginRequestAddHandler context.AcquireRequestState,AddressOf AcquireRequestStateEnd Sub Private Sub context_BeginRequest(ByVal senderAs Object,ByVal eAs EventArgs)Dim requestAs HttpRequest =CType(sender, HttpApplication).RequestDim contextAs HttpContext =CType(sender, HttpApplication).ContextDim applicationPathAs String = request.ApplicationPathIf applicationPath ="/"Then applicationPath =String.EmptyEnd If Dim requestPathAs String = request.Url.AbsolutePath.Substring(applicationPath.Length) OriginalURL = requestPath LoadCulture(requestPath) context.RewritePath(applicationPath + requestPath)End Sub Private Sub AcquireRequestState(ByVal senderAs Object,ByVal eAs EventArgs) HttpContext.Current.Session("OriginalURL") = OriginalURLEnd Sub Private Sub LoadCulture(ByRef pathAs String)Dim pathParts()As String = path.Trim("/"c).Split("/"c)If pathParts.Length > 0AndAlso pathParts(0).Length > 0Then Dim LangAs String = pathParts(0)Dim supportedLanguagesAs NameValueCollection = ResourceManager.GetSupportedLanguages()Dim supportedLanguageAs String = supportedLanguages(Lang)If Not (ResourceManager.IsNullorEmpty(supportedLanguage))Then path = path.Remove(0, pathParts(0).Length + 1)End If End If End SubEnd Class

When it is activated in web.config localization works fine but ajax not.

I get this error:

Sys is not defined

Can anybody help me ?

hello.

i think you can use fiddler to see what's happening but i'm almost positive that you're not getting the client files on the client. before rewriting the path you should check for scriptresource.axd requests and you shouldn't change the url for the those requests (they're responsible for getting the client js files onthe client side - btw, don't do it either to webresourece.axd requests)

Saturday, March 24, 2012

Ajax timer update does not work when it updates a text box with some special characters

The Ajax time seems to have some trouble updating a panel that contains a text box with some special characters. I managed to replicate the problem using a very simple page that is inlcuded below. The problem is that the second update causes an error 500 from the development server of Visual Studio.

The page just has an update panel with a single multi-line text box. The code for the timer update assignes the text box the string "<br>\n".

Does anyone know how to solve this problem?

The Page is:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox> <asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick"> </asp:Timer> </ContentTemplate> </asp:UpdatePanel> </form></body></html>
The code for the update is:

public partialclass _Default : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e) { }protected void Timer1_Tick(object sender, EventArgs e) { TextBox1.Text = "<br>\n;"; }}

Regards,

Ivan

By the way, I do realize that the problem is with special characters that trigger the ASP.NET security validations. Changing the text in the Text Box to HTML encoded is not an option, because in this text box the user should be entering and editing HTML code.