1. Conception: WebForm1 constructs a TextBox and a HyperLink control. WebForm3 (Why 3 is not 2? The following describes how to build a Calendar control. When you click the HyperLink of WebForm1, open WebForm3. Select a date in the Calendar control of WebForm3, disable WebForm3, and retrieve the date selected by TextBox in WebForm1.
2. Implementation:
1) There are ready-made date selection controls on the Internet, but considering the software security and copyright issues, you should choose your own development.
2) After obtaining the date in WebForm3, record the value to the Session and refresh WebForm1 using Javascript: window. opener. location. reload (); window. close. This method can be easily used when only one Textbox is built in WebForm1. However, if multiple TextBox is built, other TextBox contents will be cleared during refresh, therefore, it is not advisable.
3) use the ShowModalDialog method to pass the value. The specific method is as follows.
3. Specific Practices: (part of the Code)
WebForm1.aspx
<Form id = "Form1" method = "post" runat = "server">
<Asp: textbox id = "textbox1" runat = "server"> </textbox>
<Asp: hyperlink id = "hyperlink1" runat = "server" navigateurl = "javascript: void (0)" onclick = 'javascript: var str = window. showModalDialog ("webform2.aspx"); document. form1.textbox1. value = str '> </asplink>
</Form>
WebForm2.aspx
<Html>
<Head> <Frameset rows = "0, *">
<Frame src = "about: blank">
<Frame src = "WebForm3.aspx">
</Frameset>
<Html>
Note: Why do we need to build WebForm2? If WebForm2 is not built and WebForm3 is directly opened, a new window will pop up when you click the Calendar ar space to select a date in WebForm3, causing the program to run as expected. Why, limited knowledge, not clear .....
WebForm3.aspx. vb
Private Sub Calendar_selectionChanged (byval sender as object, byval e as system. eventargs) handles calendar. selectionchanged
Response. write ("<script language = 'javascript '> window. parent. returnvalue ='" & calendar. selecteddate. tostring & "'; </script>")
Response. write ("<script language = 'javascript '> window. parent. close (); </script")
End sub
4. Postscript
Similarly, other values can be passed between windows.
I would like to express my special thanks to Meng xianhui for his related articles.