从后台代码输出字符串到新页面或窗口
Output a string from code behind to a new page or window
假设代码中有一个字符串变量,其中包含一些HTML内容,例如
Dim str1 As String = "<h3>hello</h3><p>some paragraph</p><table><tr><td>some table content</td></tr></table>"
保存的文件可以通过注册一个脚本来打开,例如
Dim script1 As String = "window.open('popupPage.html', 'myPopup')"
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "someId", script1, true)
是否有办法从后面的代码在新的选项卡或窗口中输出此内容,而不将其保存到文件?
可以传递一个空字符串作为文件名
'Declare a script with your variable
Dim script1 As String = "<script>var popwin = window.open('','myPopup');popwin.document.write('" & str1 & "');</script>"
'Call your script with ScriptManager for async postback from UpdatePanel
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "poptest", script1, true)
'Call your script with ClientScript for synchronous postback outside/without UpdatePanel
ClientScript.RegisterStartupScript(Me.GetType, "popuptest", script1, True)
在服务器端代码执行后从asp.net代码调用javascript函数
相关文章:
- 在RadWindow中加载新页面,然后从加载的窗体中关闭窗口
- 如何从 jquery 中的警报弹出窗口重定向到新页面
- 打开新页面时保持弹出窗口打开状态
- 打开一个新页面作为模式窗口
- 在导航到新页面时,使 Chrome 扩展程序弹出窗口保持打开状态
- 如何在弹出窗口中显示错误消息,而不是移动到新页面
- 强制javascript在选项卡而非窗口中打开新页面
- JQuery bPopup从弹出窗口中删除旧页面,并在其中加载新页面
- 打开新页面:新窗口vs新标签
- 从后台代码输出字符串到新页面或窗口
- 如何将表单提交操作从显示警告弹出窗口更改为重定向到新页面?
- 调用一个带有HTML字符串的web新页面,以在该窗口中呈现
- 在Sharepoint上打开新页面时添加弹出窗口
- 链接打开新窗口并在父窗口上加载新页面
- 在新的窗口打开页面,没有弹出阻止使用JavaScript目标_blank
- 在ASP之后从iframe重定向到父窗口的新页面.净回发
- 在新窗口中打开一个新页面,打印并关闭它
- 在同一窗口上点击链接打开新页面
- 如何在表单提交后保持模态窗口打开并在同一模态窗口中显示新页面
- 提交表单在新的窗口和重定向当前页面不工作在Chrome