.NET Framework Bookmark and Share   
 index > JScript for the .NET Framework > concatenante javascript function into a string
 

concatenante javascript function into a string

Hi there, I'm trying to bundle the below javascript into a single string so that I can use it in a Page.RegisterStartupScript in my c# code behind. I'm stuck on how to get actualu url ("http:www.hotmail.com") included using the speech marks.

This is the script I want to concatenate

<script language="JavaScript">
window.location = "http://www.hotmail.com"
</script>

This is what I have so far:

string strScript = "<script language=JavaScript">;
strScript += "window.location =";
strScript +=" "http://www.hotmail.com" "; ???????? < this is the problem line
strScript += "</script>"

Many thanks

airwalker2000

figured out the solution:

Page.RegisterStartupScript("", "<script language=\"Javascript\">window.location=\"http://www.hotmail.com</" + "script>");


I needed the \ escape character

airwalker2000

figured out the solution:

Page.RegisterStartupScript("", "<script language=\"Javascript\">window.location=\"http://www.hotmail.com</" + "script>");


I needed the \ escape character

airwalker2000

You can use google to search for other answers

Custom Search

More Threads

• .JS/.ASP differences between IIS5 and IIS6
• Accessing a Custom Control via JavaScript
• Microsoft jscript runtime error: Automation server can't create object
• Change td width dynamically
• XMLHTTP file size limit ?
• javascript and outerhtml access across frames
• xmhttprequest.open_in_ajax
• Disable keys
• AutoComplete Extender javascript Error
• ActiveXObject("Scripting.FileSystemObject"); and network drives