当他们点击预览按钮时,我的代码需要访问页面上的控件(所以我明白我不能在这里使用web方法)。
它构建HTML并将其作为文件保存在服务器上。
我的问题是: 一旦文件生成,我想在新窗口中自动打开文件,以便用户看到他们的方便工作。
我正在使用vb.net,但很高兴收到c#的答案。
谢谢大家! 。 。
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - = - = - = - = - = - = = = - = - = - = - = - = - - 非常感谢Jan!
我仍然有一个小问题,但...
我的代码是这样的:
If fileExists Then
Do Until fileExists = False
tmpFormPreviewFileName = "Test" & GetRandomNumber() & ".html"
tmpFormPreviewFilePath = Server.MapPath("~") & "Pages\FormPreviews\" & tmpFormPreviewFileName
fileExists = My.Computer.FileSystem.FileExists(tmpFormPreviewFileName)
Loop
End If
My.Computer.FileSystem.WriteAllText(tmpFormPreviewFilePath, strHTML, False)
'Now open the file in a new window
btnPreview.OnClientClick = String.Format("window.open('/Pages/FormPreviews/{0}', 'myPopup', 'width=400,height=500')", tmpFormPreviewFileName)
所以,问题是 - 我不知道文件名是什么,直到用户有后点击预览按钮,并且OnClientClick事件将不会触发,直到用户第二次单击该按钮(这当然会创建另一个HTML文件)
- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = = = - = = = - = = = - = = = - = = - - = - - 我仍然有问题让弹出窗口工作。 这里是我的时刻代码:
'create a JavaScript command for opening the file in popup window
Dim strScript As String = String.Format("window.open('/Pages/FormPreviews/{0}, 'myPopup', 'width=400,height=500')", tmpFormPreviewFileName)
'register the JavaScript to be executed when web page loads
ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "openPopup", strScript, True)
ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "ShowMsg", "javascript:alert('Test Msg');", True)
我“ShowMsg”大火成功地,但它(弹出代码)上面的线似乎并没有工作。你能看到有什么问题吗?
2012-05-23
wotney