OnClientClick: losing backslahes in databound filename

I'm trying to open files from a linkbutton in a gridview using databound filenames by calling a filehandler.aspx page from OnClientClick as per the attached code. The filehandler.aspx window opens fine, but I'm having a problem with losing backslashes in the filename

For example, the url in the new window should be:
[..]/FileHandler.aspx?fileName=\\brkascssql\SERF_FILES\CEMTest\GB311008141857PL\test.txt
but I get:
[..]/FileHandler.aspx?fileName=\brkascssqlSERF_FILESCEMTestGB311008141857PLest.txt

Can anyone help?

<asp:LinkButton
ID="QuoteFileDescription"
runat="server"
Text='<%# Eval("Description") %>'
OnClientClick='<%# Eval("FileLocation","window.open(\"FileHandler.aspx?fileName={0}\")")%>' />

Open in new window

phillarbyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David RobitailleAnalyst ProgrammerCommented:
you should replace the "\" with "\\".
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
prairiedogCommented:
How about this?
OnClientClick='<%# String.Format("window.open('FileHandler.aspx?fileName={0}')", Eval("FileLocation")%>'

Open in new window

0
phillarbyAuthor Commented:
Prariedog.  This gives me a 'The Server tag is not well formed' error.

davrob60.  I'm not able to change the format of the filenames in teh DB if that is what you mean?
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

prairiedogCommented:
>>>Prariedog.  This gives me a 'The Server tag is not well formed' error.

It shouldn't do that. But remember though, I didn't include the close tag ("/>") for the LinkButton definition, the one I gave you is just for OnClientClick portion.
0
David RobitailleAnalyst ProgrammerCommented:
I gave you the explanation why the \ are loose. you got to replace them with something like :
Eval("FileLocation").tostring().replace("\", "\\")
But Prariedog`s solution will prevent others error from others specials char.
you may got your 'The Server tag is not well formed' error. because of the '
("window.open('FileHandler.aspx?fileName={0}')"
you may try  
("window.open(""FileHandler.aspx?fileName={0}"")"
0
phillarbyAuthor Commented:
Not sure what the probelm is, but I still get 'The Server tag is not well formed'.

For the time being I have reliased that I am able to manipulate the filename from the DB as the datasource for the grid is an ObjectDataSource, so it is up and running, but I would prefer the String.Format approach if I can get to the bottom of this problem!
<asp:LinkButton ID="QuoteFileDescription" 
runat="server" 
Text='<%# Eval("Description") %>' 
OnClientClick='<%# String.Format("window.open('FileHandler.aspx?fileName={0}')", Eval("FileLocation")%>' />

Open in new window

0
prairiedogCommented:
Try this: replace the single quote with &#39
0
prairiedogCommented:
The single quotes in window.open(&#39.....
0
phillarbyAuthor Commented:
The reason for the problem was provided, but no solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.