VB.NET中怎么访问Iframe
VB.NET中怎么访问Iframe,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
成都网站建设、成都网站设计服务团队是一支充满着热情的团队,执着、敏锐、追求更好,是创新互联的标准与要求,同时竭诚为客户提供服务是我们的理念。创新互联把每个网站当做一个产品来开发,精雕细琢,追求一名工匠心中的细致,我们更用心!
VB.NET访问Iframe前台页面:
< %@ Page Language="VB" AutoEventWireup="false"
CodeFile="mailindex.aspx.vb" Inherits="mailindex" %>< %@ Register Assembly="Microsoft.Web.UI.WebControls,
Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35"Namespace="Microsoft.Web.UI.WebControls" TagPrefix="iewc" %>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//
EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server">
< title>供應商郵件管理< /title>
< link href ="body.css" rel ="Stylesheet" type ="text/css" />
< script language ="javascript" type ="text/javascript" >
触发iframe中删除按钮的事件
function get_delbt()
{
var info=window.confirm('確定要刪除該郵件嗎?');
if (info==true)
{
//这句很关键,通过找到mainframe,运用dom访问其中的控件btdel
(删除按钮),执行服务器操作clickdocument.getElementById("mainframe").contentWindow.document.
getElementById("btdel").click();}
}
触发iframe中清空按钮的事件
function get_delallbt()
{
var info=window.confirm('確定要清空該郵件夾嗎?');
if (info==true)
{
document.getElementById("mainframe").contentWindow.document.
getElementById("btalldel").click();}
}
< /script>
< /head>
< body>
< form id="form1" runat="server">
< !--#include virtual="head.inc"-->
< div align ="center" >
< table width ="750px" background="images/back.gif">
< thead >
< tr>
< th colspan ="5" align ="left" >
< iewc:Toolbar ID="Toolbar1" Width ="400px"
DefaultStyle ="background-image:url(images/BackgroundT.bmp)"
ToolTip ="工具欄" OnButtonClick ="toolbarbt_click" runat="server">< iewc:ToolbarButton ID="inputbt"
ImageUrl="TreeLineImages/inbox.bmp" Text ="接收郵件"/>< iewc:ToolbarButton ID="newbt"
ImageUrl="TreeLineImages/unreader.bmp" Text ="撰寫郵件" />< iewc:ToolbarSeparator />
< iewc:ToolbarButton ID="delbt"
ImageUrl="TreeLineImages/unout.bmp" Text= "刪除郵件" />< iewc:ToolbarSeparator />
< iewc:ToolbarButton ID="clearbt"
ImageUrl="TreeLineImages/reback.bmp" Text ="清空郵件" />< iewc:ToolbarSeparator />
< iewc:ToolbarButton ID="infobt"
ImageUrl="TreeLineImages/hold.bmp" Text= "信息統計" />< iewc:ToolbarSeparator />
< iewc:ToolbarButton ID="addressbt"
ImageUrl="TreeLineImages/mailbox.bmp" Text ="地址薄" />< /iewc:Toolbar>
< /th>
< /tr>
< /thead>
< tbody >
< tr>
< td colspan="4" valign ="top" rowspan="2">
< iframe id="mainframe" name ="mainframe" runat ="server"
scrolling="auto" width ="600px" height ="400px" >< /iframe>< /td>
< /tr>
< tr>
< /tr>
< /tbody>
< tfoot >
< tr>
< /tr>
< /tfoot>
< /table>
< /div>
< input id="delbt1" type="button" runat ="server" value="delete" />
< input id="clearbt1" type="button" runat ="server" value="clear" />
< /form>
< /body>
< /html>
Sub toolbarbt_click(ByVal sender As Object, ByVal e As EventArgs)
Select Case sender.id.ToString
Case "inputbt"
inputmail()
Return
Case "newbt"
Response.Write("< script>javascript:window.showModelessDialog
('sendmail.aspx',window,'dialogWidth:800px;resizable:yes;');
< /script>")Return
Case "delbt"
Me.delbt1_ServerClick(delbt1, New EventArgs) '触发delbt1的click事件
Case "clearbt"
Me.clearbt1_ServerClick(clearbt1, New EventArgs)
'触发clearbt1的click事件,下面红色部分
Case "infobt"
Response.Write("< script>javascript:window.showModelessDialog
('mailinfo.aspx',window,'dialogWidth:800px;resizable:yes;');
< /script>")Return
Case "addressbt"
Response.Write("< script>javascript:window.showModelessDialog
('mailbook.aspx',window,'dialogWidth:800px;resizable:yes;');
< /script>")Return
Case Else
Response.Write("請選擇按鈕")
End Select
End Sub
Protected Sub delbt1_ServerClick(ByVal sender As Object,
ByVal e As System.EventArgs) Handles delbt1.ServerClick'调用JS方法:get_delbt().执行iframe中删除按钮的事件!
Page.ClientScript.RegisterStartupScript(GetType(String), "",
"< script>javascript:get_delbt();< /script")End Sub
Protected Sub clearbt1_ServerClick(ByVal sender As Object,
ByVal e As System.EventArgs) Handles clearbt1.ServerClick'调用JS方法:get_delallbt().执行iframe中清空按钮的事件!
Page.ClientScript.RegisterStartupScript(GetType(String), "",
"< script>javascript:get_delallbt();< /script")End Sub
看完上述内容,你们掌握VB.NET中怎么访问Iframe的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!
新闻标题:VB.NET中怎么访问Iframe
当前路径:http://scjbc.cn/article/geoosi.html