473,395 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

problem in reading server side string from client

i have an aspx page in the code behind i have
in aspx.cs
public string sPath = "C:\\Public\\User\\Other";

is aspx when I tried to get the string the slahes is gone i tried to alert
the string it gave me C:PublicUserOther , why?

<script language=javascript>
function CreateFolder()
{
var Path = '<%= sPath %>'l
alert('<%= sPath %>');
}
</script>

any help?
Nov 19 '05 #1
2 920
Raed:
Javascript, like C#, uses \ to escape values. So when you do
c:\\something\\else in c#, the string value is actually c:\something\else.
However, javascript also needs slashes escapes.

Two solutions is to change your string to:

"c:\\\\public\\\\user\\\\other";

or to escape it via:

@"c:\\public\\user\\other";

You should probably create a utility function which takes a string and
prepares it for javascript, namely escaping slashes as well as single
quotes.

Hope this helps
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
i have an aspx page in the code behind i have
in aspx.cs
public string sPath = "C:\\Public\\User\\Other";

is aspx when I tried to get the string the slahes is gone i tried to alert
the string it gave me C:PublicUserOther , why?

<script language=javascript>
function CreateFolder()
{
var Path = '<%= sPath %>'l
alert('<%= sPath %>');
}
</script>

any help?

Nov 19 '05 #2
Thank u worked perfectly

"Karl Seguin" wrote:
Raed:
Javascript, like C#, uses \ to escape values. So when you do
c:\\something\\else in c#, the string value is actually c:\something\else.
However, javascript also needs slashes escapes.

Two solutions is to change your string to:

"c:\\\\public\\\\user\\\\other";

or to escape it via:

@"c:\\public\\user\\other";

You should probably create a utility function which takes a string and
prepares it for javascript, namely escaping slashes as well as single
quotes.

Hope this helps
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
i have an aspx page in the code behind i have
in aspx.cs
public string sPath = "C:\\Public\\User\\Other";

is aspx when I tried to get the string the slahes is gone i tried to alert
the string it gave me C:PublicUserOther , why?

<script language=javascript>
function CreateFolder()
{
var Path = '<%= sPath %>'l
alert('<%= sPath %>');
}
</script>

any help?


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Lee Mundie | last post by:
Hi there, Simple problem here but can't seem to fix it! Okay, I have a select list from which people choose avatars... the list is option values ie. <option>Worm</option> ...
11
by: Abhishek | last post by:
I have a problem transfering files using sockets from pocket pc(.net compact c#) to desktop(not using .net just mfc and sockets 2 API). The socket communication is not a issue and I am able to...
3
by: Deepal | last post by:
Hi; I'm doing an example program from a book regarding .NET Remoting. Both the Client and Server are C# Console Applications. Server Code is using System; using System.Runtime.Remoting;...
15
by: Ron L | last post by:
We are working on a distributed VB.Net application which will access a SQL database located on a known server. Each client will run on the user's local machine. To implement this, we are trying...
0
by: Tim Wagaman | last post by:
I an having issuses with a loop I am running to keep checking for messages coming across our line. The goal: Listen for messages on port 5001 and print the messages into a text file. The port...
2
by: Tiraman :-\) | last post by:
Hi Everyone, i have the following problem in my client-server Application My server take array and serialize it into the memorystream Dim ns As NetworkStream = client.GetStream() Dim writer...
4
by: rs | last post by:
how I the client tell the server that the socket is closed? or this there an even that informs the server that the clients socket is close? Oh, I am using vb.net 2003 Thanks
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
9
by: Mike Reed | last post by:
I must be having a "senile" day! I cannot recall, nor get to work, code to read a cookie's expiration date/time in an ASP page/VBScript. What am I missing? *** Sent via Developersdex...
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.