. Net mode window value (C/B)

Source: Internet
Author: User

When we go to 51job.com, whether or not to select a region will pop up a beautiful form and click it. This means that they use the modal window, and the name is changed here, not the mode, I do not know the reason. I prefer to use the code of the parent page to facilitate the speech.

1 <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
3 4 5 <title> modal form parent form </title>
6 <script type = "text/javascript">
7 function B _click ()
8 {
9 var obj = new Object (); // construct an Object
10 var btnvalue = window. showModalDialog ("child.htm", obj );
11 document. getElementById ("Button1"). value = btnvalue;
12}
13 </script>
14 15 <body>
16 <input id = "Button1" type = "button" value = "region selection" onclick = "B _click ()"/>
17 </body>
18

A simple button to stimulate the click event, construct an object, display the modal form, and obtain the return value.
Paste a subpage code below

1 <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
3 4 5 <title> modal form subform </title>
6 <script type = "text/javascript">
7 function returnvalue (id)
8 {
9 if (id = 0)
10 {
11 var returnvalue = document. getElementById ("li1"). innerHTML;
12 window. returnValue = returnvalue;
13 window. close ();
14}
15 if (id = 1)
16 {
17 var returnvalue = document. getElementById ("li2"). innerHTML;
18 window. returnValue = returnvalue;
19 window. close ();
20}
21 if (id = 2)
22 {
23 var returnvalue = document. getElementById ("li3"). innerHTML;
24 window. returnValue = returnvalue;
25 window. close ();
26}
27 if (id = 3)
28 {
29 var returnvalue = document. getElementById ("li4"). innerHTML;
30 window. returnValue = returnvalue;
31 window. close ();
32}
33}
34 </script>
35 36 <body>
37 <ul>
38 <li id = "li1" onclick = "returnvalue (0)"> Beijing </li>
39 <li id = "li2" onclick = "returnvalue (1)"> Guangdong </li>
40 <li id = "li3" onclick = "returnvalue (2)"> Hangzhou </li>
41 <li id = "li4" onclick = "returnvalue (3)"> Jiangxi </li>
42 </ul>
43 </body>
44

Since it comes to transferring values, let's talk about how C # winform transfers values to web pages.

A c # Winform open the webpage and pass data
System. Diagnostics. Process. Start ("http: // localhost: 2129/Email/login. aspx? TextBox1 = 123 ");

C # Open IE and POST data
/// <Summary>
/// Open a new browser and submit POST Data
/// </Summary>
/// <Param name = "url"> address </param>
/// <Param name = "postData"> POST Data </param>
Public static void OpenNewIe (string url, string postData)
{
Var ie = new InternetExplorer ();
Object vPost, vHeaders, vFlags, vTargetFrame;
VPost = null;
VFlags = null;
VTargetFrame = null;
VHeaders = "Content-Type: application/x-www-form-urlencoded" + Convert. ToChar (10) + Convert. ToChar (13 );
If (! String. IsNullOrEmpty (postData ))
VPost = ASCIIEncoding. ASCII. GetBytes (postData );
Ie. Visible = true;
Ie. Navigate (url, ref vFlags, ref vTargetFrame, ref vPost, ref vHeaders );
}
Add microsoft internet controls reference under COM.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.