我正在寻找一种方法,只要在ASPxGridView中由GridViewCommandColumnCustomButton触发回调,就可以将PDF文件加载到iFrame上。原因是我需要加载不同的PDF,具体取决于点击ASPxGridView上的哪一行。
以下是我(不成功)处理回调的方式:
Protected Sub grid_CustomButtonCallback(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridView.ASPxGridViewCustomButtonCallbackEventArgs)
If e.ButtonID = "bnPreview" Then
Dim grid As ASPxGridView = CType(sender, ASPxGridView)
Dim key As Object = grid.GetRowValues(e.VisibleIndex, grid.KeyFieldName)
Dim sFile = UploadReportHelper.GetReport(key)
If sFile <> "" Then
frame_preview.Attributes("src") = sFile
End If
End If
End Sub
有什么想法吗?
答案 0 :(得分:1)
您的网页上必须有其他内容阻止其更新iframe。如果你将它隔离到另一个项目中就可以了。我刚刚创建了一个新项目并进行了测试。下面的作品。
<强> HTML:强>
<iframe id="myFrame" runat="server"
src="http://dell.com" width="100%" height="600">
Your browser doesn't support iframes
</iframe>
<asp:Button ID="myButton" runat="server"
Text="Change IFRAME Source" />
<强>代码隐藏:强>
Protected Sub myButton_Click(sender As Object,
e As System.EventArgs) Handles myButton.Click
myFrame.Attributes("src") = "http://microsoft.com"
End Sub
在这种情况下,您只需将UpdateMode
上的UpdatePanel
设置为Conditional
,然后在CodeBehind中调用.Update()
UpdatePanel
方法如下所示。
<强> HTML:强>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<p>
<strong>Today's Date:</strong> <%=Now.ToString()%>
</p>
<asp:UpdatePanel ID="myUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<iframe id="myFrame" runat="server"
src="http://dell.com" width="100%" height="600">
Your browser doesn't support iframes
</iframe>
<p>
<asp:Button ID="myButton" runat="server"
Text="Change IFRAME Source" />
</p>
</ContentTemplate>
</asp:UpdatePanel>
<强>代码隐藏:强>
Protected Sub myButton_Click(sender As Object,
e As System.EventArgs) Handles myButton.Click
myFrame.Attributes("src") = "http://microsoft.com"
myUpdatePanel.Update()
End Sub