Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 206065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:36:44+00:00 2026-05-11T17:36:44+00:00

I am trying to generate a URL that contains a UNC path as one

  • 0

I am trying to generate a URL that contains a UNC path as one of the query string variables. The URL will open in a pop up window when an ASP.NET button control is clicked by the user. When the clicks the button, the backwards slashes are removed from the UNC path causing the page to break.

The button renders correctly in the page source file with all the backward slashes.

Is there any way to prevent this?

Here is my source code:

Code behind:

string unc = @"\\myserver\myfolder\myfile.txt";
string url = string.Format("http://www.mysite.com/page.aspx?a={0}", unc);

MyButton.Attributes.Add("onclick", @"javascript:FullPop('" + url + @"')");

ASPX page

<script language="javascript" type="text\javascript">
    function FullPop(Newurl) {
        Win = window.open( Newurl,"Monitor", "fullscreen=0,toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width=800,height=600,top=50,left=50");
        Win.focus();
    }
</script>

<asp:button id="MyButton" runat="server" cssclass="mycss" text="View Actual Target" />

Update

Server.UrlEncode does not work. Same behavior.

Update 1

Based on Daniel Lew’s answer, I developed the following solution:

protected void Page_Load(object sender, EventArgs e)
{  
    string unc = @"\\myserver\myfolder\myfile.txt";
    string url = string.Format("http://www.mysite.com/page.aspx?a={0}", unc);

    MyButton.Attributes.Add("onclick", @"javascript:FullPop('" + this.EscapeforJavaScript(url) + @"')");
}

private string EscapeforJavaScript(string url)
{
    return url.Replace(@"\", @"\\"); 
}
  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:36:44+00:00Added an answer on May 11, 2026 at 5:36 pm

    You have to URL encode the value that you put in the URL:

    string url = "http://www.mysite.com/page.aspx?a=" + Server.UrlEncode(unc);
    

    Edit:
    To safely put the url in the Javascript code, you also have to encode the string for being a literal string:

    MyButton.Attributes.Add("onclick", @"FullPop('" + url.Replace(@"\", @"\\").Replace("'", @"\'") + @"')");
    

    (The javascript: protocol is only used when the Javascript is used as href for a link, not when you put code in an event like onclick.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to dynamically generate root folder in a url that's in the body
I want to generate the string like SEO friendly URL. I want that multiple
So I'm trying to generate the right URL to go in the facebook Like
I am trying to understand crc32 to generate the unique url for web page.
I'm trying to generate a report of the activities that users have done within
I'm trying to send a string of XML as part of the query string.
I'm developing (trying for now) portlet that will be integrated with LinkedIn. Following the
I'm trying to generate an actionlink on a page that has the following route:
I'm trying to map certain routes so that auto generated Urls will look like
I'm trying to generate JSON in php. My problem is that some backslashes stays

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.