C#.net中用WinForm接收html页面消息的程序
首先写一个页面,上面要放一个Button
<html>
<head>
<title></title>
</head>
<body>
<input id="Button1" type="button" value="button" />
</body>
</html>
将其保存在HomePage.htm中,
之后我们建一个WinForm,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SXT.Frame.Ctrler.Test
{
public partial class HtmlUi : Form
{
public HtmlUi()
{
InitializeComponent();
this.webBrowser1.Navigate("D:\\SXT\\bin\\Debug\\HomePage.htm");//本地文件路径
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlDocument htmlDoc = this.webBrowser1.Document;
HtmlElement btnElement = htmlDoc.All["Button1"];
if (btnElement != null)
{
btnElement.Click += new HtmlElementEventHandler(btnElement_Click);
}
}
void btnElement_Click(object sender, HtmlElementEventArgs e)
&n
相关文档:
冒泡排序
using System;
class Program
{
public static void Main()
{
int[] a = new int[10];
Random rand = new Random();
for (int i = 0; i < 10; i++)
{
a[i] = rand.Next(10);//生成随机数给数组赋值
}
for (int i = 0; i < ......
public void ExportControl(System.Web.UI.Control source, string DocumentType, string filename)
{
//设置Http的头信息,编码格式
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearContent();
......
//获取包含清单的已加载文件的路径或 UNC 位置。
public static string sApplicationPath = Assembly.GetExecutingAssembly ( ).Location;
//result: X:\xxx\xxx\xxx.dll (.dll文件所在的目录+.dll文件名)
//获取当前进程的完整路径,包含文件名(进程名)。
string str = this.GetType ( ).Assembly.Location;
//result ......
c# 中 is和as 操作符是用来进行强制类型转换的
is : 检查一个对象是否兼容于其他指定的类型,并返回一个Bool值,永远不会抛出异常
object o = new object();
if (o is Label)
{
Label lb = (Label)o;
Response.Write("类型转换成功");
}
else
{
Response.Write(" ......
有關html窗體框架的問題,如果想要實現在一個畫面中分割窗體,並且通過點擊其中的一個窗體,鏈接內容至同一個畫面中的另一個窗體。就需要使用<frameset>與<frame>的 ......