简体   繁体   English

单击按钮将数据从一个asp.net页发布到另一页

[英]Posting datas from one asp.net page to another when click a button

I have 2 ASP.Net WebForm named as webform1.aspx,webform2.aspx. 我有2个ASP.Net WebForm,分别名为webform1.aspx,webform2.aspx。 Webform1.aspx contain Register area with textboxes for name,address,age etc to register Student Profiles. Webform1.aspx包含带有名称,地址,年龄等文本框的注册区域,用于注册学生资料。 Webform2.aspx contain a messge area to ensure that the Registred student is valid. Webform2.aspx包含一个信息区,以确保注册学生有效。

I have a Submitt Button in webform1.aspx. 我在webform1.aspx中有一个Submitt按钮。 Upon clicking, it will post the Register datas to Message area of Webform2.aspx &If Valid it post to database. 单击后,它将把“注册数据”发布到Webform2.aspx的“消息”区域。如果有效,它将发布到数据库。 So, how can I do it for get the details from one form to another? 因此,如何将详细信息从一种形式获取到另一种形式? I want code in C#.net. 我想要C#.net中的代码。

Having 2 aspx pages to do this simple registration task is not really how you should go about ASP.net programming. 拥有2个aspx页来完成此简单的注册任务实际上并不是您应该进行ASP.net编程的方式。

The standard ASP.net way of doing this would be: Start with one page aspx which has: 执行此操作的标准ASP.net方法是:从一页aspx开始,该页具有:

  • the name, address, password inputs 名称,地址,密码输入
  • a submit button 提交按钮
  • a message area 信息区

Set the message area to be invisible (in the IDE right click it and select Properties). 将消息区域设置为不可见(在IDE中右键单击它,然后选择“属性”)。

Add an onclick function to the submit button (in the IDE double-click on the button) and in that function put all the validation code, and code to make the name, address, password and submit inputs invisible and make the message area visible. 在提交按钮上添加一个onclick函数(在IDE中双击该按钮),然后在该函数中放入所有验证代码,以及使名称,地址,密码和提交输入不可见并使消息区域可见的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM