While working on creating a JavaScript code with an URL in the code-behind page using C#, I encountered an issue where the URL parameter inside the JavaScript was not in the correct format after being generated by C#.
For example:
URL parameter:
JavaScript: javascript:dnnModal.show('',false,365,206,false)
C# code:
string link = "http://google.com?popUp=true";
string googleIcon = "<a href='javascript:dnnModal.show('" + link +',false,365,206,false)'><img border='0' src='~/Icons/gIcon.png'></a>";
Upon viewing the aspx page's source code, I noticed that the generated googleIcon code had an incorrect format:
<a href="javascript:dnnModal.show(" http:="" google.com?popup="true',false,365,206,false)'"><img src="~/Icons/gIcon.png" border="0"></a>
When hovering over the icon hyperlink, only part of the JavaScript string was displayed. The URL and other parts were lost in translation.
I am seeking assistance in resolving this issue and learning how to properly pass an URL parameter into JavaScript using C#.