什么是使用的window.external? [英] What is the use of window.external?

查看:307
本文介绍了什么是使用的window.external?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是使用的window.external?这是用来调用服务器端函数/在C#/ VB.NET(ASP.NET)从JavaScript的方法呢?能否请你指出我朝着正确的方向?

感谢

错误:

 <%@页面语言=VBAutoEventWireup =false的codeBehind =WebForm1.aspx.vb继承=WebApplication1.WebForm1%GT;!< D​​OCTYPE HTML PUBLIC -  // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
<头=服务器>
    <标题>< /标题>
< /头>
<身体GT;
    <表ID =form1的=服务器>
    < D​​IV>
        <输入类型=按钮NAME =Button1的价值=点击的onclick =JavaScript的:window.external.SayHello('迈克'); />
    < / DIV>
    < /表及GT;
< /身体GT;
< / HTML>公共类WebForm1的
    继承System.Web.UI.Page    公用Sub的SayHello(BYVAL名作为字符串)
        的Response.Write(你好 - &放大器;名称)
    结束小组末级


解决方案

这在很大程度上是由这个采取MSDN文章,但的window.external 可以用来让你的 WebBrowserControl 来执行你的客户端Windows的公共方法表单应用程序。

例如在表单中你可能有一个功能,如:

 公共无效HelloFromTheForm()
{
    的MessageBox.show(嗨客户,感谢您给我打电话!);
}

和在加载到你的HTML WebBrowserControl 你可以有一个按钮,如下:

 <按钮的onclick =window.external.HelloFromTheForm()>
    打招呼的形式
< /按钮>

因此​​,在针对您的问题,这是用来调用服务器端的功能是什么?,你的表格是不是服务器端,但它确实让你调用C#/ VB.NET code的您的形式从嵌入式网页。

What is the use of window.external ? Is this used to call the server side functions / methods in C# / VB.NET (ASP.NET) from JavaScript ? Can you please point me in right direction ?

Thanks

Error:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1" %>

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="button" name="button1" value="Click" onclick="javascript:window.external.SayHello('Mike');" />
    </div>
    </form>
</body>
</html>

Public Class WebForm1
    Inherits System.Web.UI.Page

    Public Sub SayHello(ByVal name As String)
        Response.Write("Hello :- " & name)
    End Sub

End Class

解决方案

This is largely taken from this MSDN article but window.external can be used to allow your WebBrowserControl to execute public methods of your client Windows Forms application.

For example in your form you may have a function such as:

public void HelloFromTheForm()
{
    MessageBox.Show("Hi client, thanks for calling me!");
}

And in the html loaded into your WebBrowserControl you may have a button that looks like:

<button onclick="window.external.HelloFromTheForm()">
    Say hi to the form
</button>

So in regards to your question of 'Is this used to call the server side functions?', your form isn't 'server side' but it does allow you to call the C#/VB.NET code of your form from an embedded webpage.

这篇关于什么是使用的window.external?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆