Click here to Skip to main content
15,904,297 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a function which returns an html code what I want to do is that i want to open html returned by the function in the pop up window. Help me how can i do that.. I m using this code..But it is giving "resource could not found " error. Here my Print Occupant function returns html.

<br />
string html = objEmailUtility.PrintOccupant(occupantsArrayList, objOccchkDTO);<br />
                    StringBuilder sb = new StringBuilder();<br />
<br />
                    sb.Append("<script>");<br />
                    sb.Append("window.open('html', '', '');");<br />
                    sb.Append("</script>");<br />
<br />
                    Page.RegisterStartupScript("test", sb.ToString());<br />

Plz Guide
Posted

1 solution

XML
< HEAD>
< SCRIPT LANGUAGE="JavaScript" type="text/javascript>
< !-- Begin
newWindow = window.open('','newWin','toolbar=yes,location=yes,
scrollbars=yes,status=yes,width=630,height=400')
The above line was broken in two for display purposes only!
newWindow.document.write
("<HTML>
< HEAD>
< TITLE>window!</TITLE>
< /HEAD>
< BODY bgcolor='#FFFFFF' text='#000000' background='../Images/RoughGrey.gif'>
< DIV ALIGN='center'>
< H1><font color='#990000'>This is pretty cool stuff!</font></H1>
< IMG SRC='../Images/HouseOfWacks.jpg' width='535' height='268'>
< /DIV>
< /BODY>
< /HTML> ")
newWindow.document.close
// End -->
< /SCRIPT>
< /HEAD>



OR

Refer :

http://webwonks.org/WebBuilding/PopupWindows.html[^]

go to "Creating ad hoc pages and filling them with HTML" and check live example.
 
Share this answer
 
v2
Comments
touseef4pk 31-May-11 7:32am    
Hi! i could not understand this code... what about the html which i have stored in variable(named html) of type string? How will i implement my logic in your code..?
Kiran Sonawane 31-May-11 7:38am    
newWindow.document.write(your_variable_which_contain_html)

Make sure your html attributes should be enclosed with single quote (not double quote). for instance, < DIV ALIGN='center'></DIV>, AND NOT

DIV ALIGN="center"></DIV>
touseef4pk 31-May-11 8:40am    
thanks it works now

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900