About data returns to the call page

xiaoxiao2021-03-06  61

We often need to return data to the call page, below is the basic implementation. Suppose, there are two page selectdate.aspx, calendar.aspx. You need to make a connection in SelectDate.aspx, click Calendar.aspx, then select the date in Calendar.aspx, return the selected date to SelectDate.aspx ( Oh, I don't know if I understand it. I don't have it. Let's take a look at the code. I naturally understand.

Yes, you need a file to use JavaScript script.js =================================== ============================================================================================================================================================================================================= ========== Selectdate.aspx ------------------------------------- --- <% @ page language = "c #" codebehind = "detail.aspx.cs" autoeventwireup = "false" inherits = "caledar.detail"%> Detail </ title> <meta name =" generator "content =" Microsoft Visual Studio .NET 7.1> <meta name = "code_language" content = "c #" "CONTENT =" C # " > <meta name = "vs_defaultClientScript" content = "JavaScript"> <meta name = "vs_targetSchema" content = "http://schemas.microsoft.com/intellisense/ie5"> <script language = "javascript" src = "script .JS "> </ script> </ hEAD> <body> <form id =" form1 "method =" post "runat =" server "> <ask: textbox id =" complex) "style =" z-index: 101 Left: 120px; position: absolute; top: 72px "Runat =" server "> </ ask: textbox> <a href="javascript:Opencalendar ('" <img style', "</p> <p>Z-Index: 102; Left: 296px; Width: 24px; Position: absolute; top: 72px; height: 16px "Height =" 16 "alt =" SRC = "img / calendar.gif" width = "24"> </a> </ form> </ body> </ html> ---------------------------------- ---------------------------------- SelectDate.aspx.cs ----------- -------------------------------------------------- --------- Sing system; use system.collections; use system.componentmodel; using system.data; using system.drawing; using system.web; using system.Web.SessionState; Using System.Web.ui Using system.web.ui.webcontrols; using system.web.ui.htmlControls; Namespace Calendar {/// <summary> /// detail's summary description. /// </ summary> Public Class Detail: System.Web .Ui.page {protected ;.textbox completionDate; private void page_load (Object sender, system.eventargs e) {// Place user code here to initialize page}</p> <p>#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} /// <summary> /// Designer Supports the required method - Do not use the code editor to modify the // / this method. /// </ summary> private () {this.load = new system.eventhandler (this.page_load);</p> <p>} #Endregion}}}</p> <p>============================================================================================================================================================================================================= ========================= Calendar.aspx ====================== ============================================================================================================================================================================================================= = <% @ Page language = "c #" codebehind = "calendar.aspx.cs" autoeventwireup = "false" inherits = "calendar.webform1"%> <! Doctype html public "- // w3c // DTD HTML 4.0 Transitional / / En "> <html> <head> <title> Webform1 </ title> <meta name =" generator "content =" Microsoft Visual Studio .NET 7.1> <meta name = "code_language" Content = "C #"> < meta name = "vs_defaultClientScript" content = "JavaScript"> <meta name = "vs_targetSchema" content = "http://schemas.microsoft.com/intellisense/ie5"> <script language = "javascript"> function CloseWindow () { Self.close ();} </ script> </ head> <body> <form id = "calendar" method = "post" runat = "server"> <ask: calendar id = "CAL" style = "z- INDEX: 101;</p> <p>LEFT: 96PX; POSITION: ABSOLUTE; TOP: 16PX "Runat =" Server "BorderWidth =" 1px "backcolor =" # fffcc "width =" 220px "daynaMeformat =" firstletter "forcolor =" # 663399 "Height =" 200px "font -Size = "8pt" Font-Names = "Verdana" BorderColor = "# FFCC66" ShowGridLines = "True"> <TodayDayStyle ForeColor = "White" BackColor = "# FFCC66"> </ TodayDayStyle> <SelectorStyle BackColor = "# FFCC66 "> </ SelectorStyle> <NextPrevStyle Font-Size =" 9pt "ForeColor =" # FFFFCC "> </ NextPrevStyle> <DayHeaderStyle Height =" 1px "BackColor =" # FFCC66 "> </ DayHeaderStyle> <SelectedDayStyle Font-Bold = "True" backcolor = "# ccccff"> </ selectedDayStyle> <titlesty font-size = "9pt" font-bold = "true" forecolor = "# fffcc" backcolor = "# 990000"> </ titlestyle> <OtherMonthdayStyle Forecolor = "# Cc9966"> </ ostHDHDAYSTYLE> </ ask: Calendar> <askTON "style =" z-index: 102; Left: 96px; position: absolute; top: 224px "runat =" Server "Text =" o K "> </ ask: button> <a href="javascript:closeWindow()"> <asp: button id =" cancelbutton "s Tyle = "z-index: 103; Left: 136px; position: absolute; top: 224px" Runat = "server" text = "cancel"> </ asp: button> </a <ask: label id = "lbldate "style =" z-index: 104; Left: 216px;</p> <p>Position: absolute; top: 232px "Runat =" server "> </ ask: label> <ask: DropDownList ID =" MONTHSELECT "style =" Z-Index: 105; Left: 96px; position: absolute; top: 256px " Runat = "server" autopostback = "true"> </ ask: DropDownList> <ask: DropDownList ID = "Yearslect" style = "z-index: 106; Left: 248px; position: absolute; top: 256px" runat = " Server "autopostback =" true "> </ ask =" datechosen "type =" hidden "name =" datechosen "runat =" server "> // This is very important </ form> </ body> </ Html> ---------------------------------------------- -------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- -------------------------------------------------- ---- using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web .Ui.webcontrols; using system.web.ui.htmlControls; Using Sys Tem.configuration;</p> <p>A summary description of Namespace Calendar {/// <summary> /// WebForm1. /// </ summary> public class WebForm1: System.Web.UI.Page {protected System.Web.UI.WebControls.Calendar Cal; protected System.Web.UI.WebControls.Button OKButton; protected System.Web.UI. WebControls.Button CancelButton; protected System.Web.UI.WebControls.Label lblDate; protected System.Web.UI.WebControls.DropDownList MonthSelect; protected System.Web.UI.HtmlControls.HtmlInputHidden datechosen; protected System.Web.UI.WebControls. DropDownList YearSelect; private void Page_Load (object sender, System.EventArgs e) {if (Page.IsPostBack!) {string selected = Request.QueryString [ "selected"]; string id = Request.QueryString [ "id"]; string form = Request.QueryString [ "formname"]; string postBack = Request.QueryString [ "postBack"]; Cal.FirstDayOfWeek = (System.Web.UI.WebControls.FirstDayOfWeek) 1; // (System.Web.UI.WebControls. Firstdayofweek) Convert.Toint32 (ConfigurationSettings.appsettings [global.cfgkeyfirstdayofweek]); try {ca.selectedDate = C Al.visibleDate = Convert. TodateTime (SELECTED);} catch {cal.selectedddate = caverndault (); selectcorRectValues ​​();</p> <p>Okbutton.attributes.add ("onclick", "Window.opener.Setdate ('" form ",'" id ", Document.calendar.datechosen.Value," Postback ");") CancelButton.attributes.add ("onclick", "closewindow ()");} // Place user code here to initialize page} private void FillCalendarchoices () {datetime thisdate = new datetime (datetime.today.year, 1 , 1); for (int x = 0; x <12; x ) {listitem li = new listitem (thisdate.Tostring ("mmmm"), thisdate.month.tostring ()); MontHselect.Items.Add (Li) ThundDate = thisdate.addmonths (1);} for (int y = 1994; y <= thisdate.year; y ) {YEHSELECT.ITEMS.ADD (Y.ToString ());}} private void selectcorRectValues ​​() {lbldate .Text = Cal.SelectedDate.ToShortDateString (); datechosen.Value = lblDate.Text; MonthSelect.SelectedIndex = MonthSelect.Items.IndexOf (MonthSelect.Items.FindByValue (Cal.SelectedDate.Month.ToString ())); YearSelect.SelectedIndex = YEARSELECT.ITEMS.Indexof (Yearsect.Items.FindByValue (Cal.SelectedDdate.year.toString ()));} SelectionChanged (Object Sender, System.EventArgs E) {Cal.VisibleDate = CAL.SelectedDate; selectCorRectValues ​​();</p> <p>private void MonthSelect_SelectedIndexChanged (object sender, System.EventArgs e) {Cal.SelectedDate = Cal.VisibleDate = new DateTime (Convert.ToInt32 (YearSelect.SelectedItem.Value), Convert.ToInt32 (MonthSelect.SelectedItem.Value), 1) ;; SelectcorRectValues ​​();</p> <p>private void YearSelect_SelectedIndexChanged (object sender, System.EventArgs e) {Cal.SelectedDate = Cal.VisibleDate = new DateTime (Convert.ToInt32 (YearSelect.SelectedItem.Value), Convert.ToInt32 (MonthSelect.SelectedItem.Value), 1) ;; SelectCorRectValues ​​();} #Region Web Form Designer Generated Code Override Protected Void OnInit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} /// <summary> /// Designer Supports the required method - Do not use the code editor to modify the // / this method. /// </ summary> private void InitializeComponent () {this.Cal.SelectionChanged = new System.EventHandler (this.Cal_SelectionChanged); //this.OKButton.Click = new System.EventHandler (this.OKButton_Click); / /this.CancelButton.Click = new System.EventHandler (this.CancelButton_Click); this.MonthSelect.SelectedIndexChanged = new System.EventHandler (this.MonthSelect_SelectedIndexChanged); this.YearSelect.SelectedIndexChanged = new System.EventHandler (this.YearSelect_SelectedIndexChanged ); This.Load = new system.eventhandler (this.page_load); this.id = "Calendar";</p> <p>} #Endregion</p> <p>Private Void CancelButton_Click (Object Sender, System.EventArgs E) {}</p> <p>Private void okbutton_click (object sender, system.eventargs e) {}}} ==================================== ============================================================================================================================================================================================================= ====== script.js =========================================== =================================================== var Popup; function opencalendar (idName, Postback {popup = WINDOW.OPEN ('Calendar.aspx? formname =' Document.Forms [0] .Name '& ID =' IDNAME '& SELECTED =' Document.Forms [0] .Elements [idName] .Value '& postback =' postback, 'popupcal', 'width = 285, height = 420, left = 200, top = 250');</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-84760.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="84760" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.039</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '8z1di3TG2Ri0E7gRmGWLyXF0qhYy_2FpXTDI8BBQONN0RwW6hqB8XMNIudBRe_2FJT3nLKZvgO3TY47n3FaRwVRYkw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>