如何从asp网页到客户端webbrowser控件获取动态分配的文本框值 [英] How to get the dynamically assigned textbox values from asp webpage to a client side webbrowser control

查看:137
本文介绍了如何从asp网页到客户端webbrowser控件获取动态分配的文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我开发了一个在互联网上托管的网页;在第一页中,它将通过文本框和sendbutton接受一些输入值;这些值将被发送到第二页并保存到第二个网页中动态创建的文本框中。



我正在开发一个带有webbrowser控件的客户端Windopws应用程序想要访问保存在第二页中的文本框值,这些值是由asp代码动态保存的。



这是Internet上托管的第二个ASP页面代码: -



< html>

< head>



< / head>



< body>

<%



val1 =请求.form(number1)

val2 = Request.form(number2)



Response.write(< input type = text name = num1 id = num1 value =+ val1 +>)



Response.write(< input type = text name = num2 id = num2 value =+ val2 +>)



%>



< / body>

< / html>



我的客户端C#webbrowser控制代码当Document Completed事件触发时,访问上面代码中创建的文本框值: -



void myWb_DocumentCompleted(object sender,WebBrowserDocumentCompletedEventArgs e)

{



if(myWb.Url.ToString()。ToLower()。包含(http://mywebpage.asp))

{



MessageBox.Show(myWb.Url.ToString());



MessageBox .Show(myWb.Document.GetElementById(num1)。InnerText);

MessageBox.Show(myWb.Document.GetElementByName(num2)。InnerText.ToString());

}

}



但是,只有URL属性显示网站的正确URL时,两个消息框都显示为null目前正在显示。



我的Visual Studio版本是2012.



请求您立即帮助解决此问题。



非常感谢。

Hi,

I have developed a web page hosted in internet; where in the first page it will accept some input values through textboxes and upon sendbutton ; those values will be sent to the second page in and get saved into dynamically created textboxes in second webpage.

I am developing a client side Windopws application with webbrowser control and I want to access the Textbox values saved in the second page which are dynamically saved by asp code.

Here is the second ASP page code hosted in Internet:-

<html>
<head>

</head>

<body>
<%

val1=Request.form("number1")
val2=Request.form("number2")

Response.write("<input type=text name=num1 id=num1 value=" + val1 + ">")

Response.write("<input type=text name=num2 id=num2 value=" + val2 + ">")

%>

</body>
</html>

My client side C# webbrowser control code to access the textbox values created in the above code when the Document Completed event triggers:-

void myWb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{

if (myWb.Url.ToString().ToLower().Contains("http://mywebpage.asp"))
{

MessageBox.Show(myWb.Url.ToString());

MessageBox.Show(myWb.Document.GetElementById("num1").InnerText);
MessageBox.Show(myWb.Document.GetElementByName("num2").InnerText.ToString());
}
}

But both the Message boxes displaying null only though the URL property displays the correct URL of the website currently displaying.

My Visual studio version is 2012.

Request your immediate help to fix this issue.

Thank You Very Much.

推荐答案

这篇关于如何从asp网页到客户端webbrowser控件获取动态分配的文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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