首页 新闻 会员 周边

Winform程序操作web页面

0
[已解决问题] 解决于 2011-06-03 13:05
winfrom界面上有一个textbox、一个button;web界面上有一个textbox,当我点击winform界面上的button按钮,将winform界面上textbox中的值赋值给web界面上的textbox;
依然、依旧的主页 依然、依旧 | 初学一级 | 园豆:4
提问于:2011-06-02 19:41
< >
分享
最佳答案
0

htm文件内容

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
</head>

<body>
<script type="text/javascript">
function write(str) {
document.getElementById(
"target").value = str;
}
</script>
<input type="text" id="target" />
</body>
</html>

winform代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace InterOperate
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Document.InvokeScript(
"write",new string[]{textBox1.Text});
}

private void Form1_Load(object sender, EventArgs e)
{
string path = System.Windows.Forms.Application.StartupPath;
webBrowser1.Url
=new Uri(path + "/test.htm");
}
}
}

麦田里的守望者 | 菜鸟二级 |园豆:428 | 2011-06-03 10:07
其他回答(2)
0

你没开玩笑吧!

梅莲芳 | 园豆:669 (小虾三级) | 2011-06-03 09:18
你看我像是在开玩笑吗?
支持(0) 反对(0) 依然、依旧 | 园豆:4 (初学一级) | 2011-06-03 09:23
@依然、依旧:你确定用窗口程序给web页面赋值?
支持(0) 反对(0) 梅莲芳 | 园豆:669 (小虾三级) | 2011-06-03 09:28
0

强银

JCdon | 园豆:2 (初学一级) | 2011-06-03 10:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册