phillarby
asked on
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?file Name=\\brk ascssql\SE RF_FILES\C EMTest\GB3 1100814185 7PL\test.t xt
but I get:
[..]/FileHandler.aspx?file Name=\brka scssqlSERF _FILESCEMT estGB31100 8141857PLe st.txt
Can anyone help?
For example, the url in the new window should be:
[..]/FileHandler.aspx?file
but I get:
[..]/FileHandler.aspx?file
Can anyone help?
<asp:LinkButton
ID="QuoteFileDescription"
runat="server"
Text='<%# Eval("Description") %>'
OnClientClick='<%# Eval("FileLocation","window.open(\"FileHandler.aspx?fileName={0}\")")%>' />
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
davrob60. I'm not able to change the format of the filenames in teh DB if that is what you mean?
>>>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.
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.
I gave you the explanation why the \ are loose. you got to replace them with something like :
Eval("FileLocation").tostr ing().repl ace("\", "\\")
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}"")"
Eval("FileLocation").tostr
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=
you may try
("window.open(""FileHandler.aspx?fileName=
ASKER
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!
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")%>' />
Try this: replace the single quote with '
The single quotes in window.open('.....
ASKER
The reason for the problem was provided, but no solution.
Open in new window