Reputation: 554
This could be a simple but I havent found any easy solution.
On clicking button in asp.net web page on button click event html is generated from xml and xsl. This html is stored as string variable. For example lets say
dim htmlString as string = "<div>This is my popup</div>"
From the above html string how can I dynamically create html popup window in vb.net. I can create popup window on front end by using javascript but havent found any solution to create it through code behind file in vb.net
Edit:
This does not work in IE, only works in firefox:
Dim popupScript As String = _
"<script language='javascript'> myPopup() </script>"
Dim mystring = "<html><body><div style=""color:black"">Name: Jame's</div></body></html>"
Page.ClientScript.RegisterStartupScript(Me.GetType(), "PopupScript", String.Format(popupScript))
Upvotes: 0
Views: 15513
Reputation: 460158
You can only create a popup-window with javascript, so you need to register that script from codebehind:
ClientScript.RegisterStartupScript(Me.GetType(), "newWindow", String.Format("<script>window.open('{0}');</script>", url))
Maybe i've misunderstood your requirement. You want not only to open a client-side popup(window.open
) from codebehind but also create that window on the fly without url?
Maybe this helps(untested):
Dim popupHtml = "<html><body><div style=""color:black"">Name: Jame's</div></body></html>"
Dim openPopupScript = "NewPopup=window.open("", 'newWindow', 'height=250, width=250');" & _
"NewPopup.document.open();" & _
String.Format("NewPopup.document.write('{0}');", popupHtml) & _
"NewPopup.document.close();"
ClientScript.RegisterStartupScript(Me.GetType(), _
"newWindow", _
openPopupScript)
Upvotes: 3