Triple Quotes? How do I delimit a databound Javascript string parameter in ASP.NET?

I had recently similar problem and the only way to solve it was to use plain old HTML codes for single ( ' ) and double quotes ( " ).

Up vote 7 down vote favorite 1 share g+ share fb share tw.

I have an anchor tag in an ASP. NET Repeater control. The OnClick event of the anchor contains a call to a Javascript function.

The Javascript funciton takes a string for it's input parameter. The string parameter is populated with a databound value from the Repeater. I need the 'double quotes' for the Container.DataItem.

I need the 'single quotes' for the OnClick. And I still need one more delimiter (triple quotes? ) for the input string parameter of the Javascript function call.

Since I can't use 'single quotes' again, how do I ensure the Javascript function knows the input parameter is a string and not an integer? Without the extra quotes around the input string parameter, the Javascript function thinks I'm passing in an integer. Cheers in advance for any knowledge you can drop.

The anchor: );' >Show/Hide and here is the Javascript: asp.net javascript anchor quotes link|improve this question edited Aug 5 '08 at 4:45Jeff Atwood?20.3k2688103 asked Aug 5 '08 at 4:05David HAust1,98031527 80% accept rate.

I had recently similar problem and the only way to solve it was to use plain old HTML codes for single (') and double quotes ("). Source code was total mess of course but it worked. Try ");'>Show/Hide or ');'>Show/Hide.

Winna! Thanks Lubos. HTML codes sorted it (and yep, it was messy, but it works).

Solution: onclick='ToggleDisplay("");' – David HAust Feb 8 '10 at 3:50 1 " is double quote. ' is single quote – Mahesh Jan 11 '11 at 11:07.

Without the extra quotes around the input string parameter, the Javascript function thinks I'm passing in an integer. Can you do some rudimentary string function to force JavaScript into changing it into a string? Like value = value.

Try putting the extra text inside the server-side script block and concatenating. Onclick='' Edit: I'm pretty sure you could just use double quotes outside the script block as well.

Onclick='javascript:ToggleDisplay(" "); ' Use like above.

Passing variable to function without single quote or double quote test.

I just tried using the 'Format String' parameter for the DataBinder. Eval but that didn't work either. Onclick.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions