Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Server.UrlEncode
Message
From
14/01/2008 13:38:04
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01281652
Message ID:
01281661
Views:
6
>Hi everybody,
>
>How can I find out what Server.UrlEncode is supposed to do?
>
>The code is creating a QueryString which includes title for the page. When I put ' in the title the website blows up and gives me an error "expected ;" from the JavaScript which brings me to the wrong QueryString.
>
>I'm not sure how can I fix this problem to allow typing anything in the Title?
>
>This is not actually the problem I have to fix, but since I found it, I want to fix it as well.
>
>I'm also wondering where can I ask questions regarding fckEditor? I tried their forum but didn't get many responses so far...
>
>Thanks a lot in advance.

As far as your first question, Server.UrlEncode transforms a querystring to properly formatted URL specifications. I use it for all of my URLs that use querystring. Are you including the entire URL in the method, or just the querystring section? Here is an example from my Webform Base class.
    Protected Sub NavigateTo(ByVal location As String, _
                                Optional ByVal parms As NameValueCollection = Nothing)

        Dim link As New StringBuilder

        link.Append(Me.VirtualRoot)
        link.Append(location)

        If Not parms Is Nothing Then
            link.Append("?")
            For i As Integer = 0 To parms.Count - 1
                link.Append(Server.UrlEncode(parms.Keys.Get(i)) & "=" & Server.UrlEncode(parms(i)))
                link.Append("&")
            Next
            'Remove the last "&"
            link.Remove(link.Length - 1, 1)
        End If

        Response.Redirect(link.ToString)

    End Sub
Very fitting: http://xkcd.com/386/
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform