[英]how .aspx page work and what happens when i send the request to .aspx page first time?
I got stuck here and I want to know how they actually.aspx page work when I send the request for the.aspx page the first time how HTML comes to the browser and when I click on the button what happens behind how the.aspx page gets executed and I want to know does it really need to know this in detail?我被困在这里,我想知道当我第一次发送对 .aspx 页面的请求时,它们实际上是如何工作的被执行,我想知道它真的需要详细了解吗? and how.
如何。 Does the aspx.cs page work?
aspx.cs 页面是否有效?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace sample1
{
public partial class First : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("Welcome");
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="First.aspx.cs" Inherits="sample1.First" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Click" OnClick="Button1_Click" />
</div>
</form>
</body>
</html>
Please go through this: ASP.NET Page Life Cycle Overview请 go 通过此: ASP.NET 页面生命周期概述
Understanding Page.IsPostBack Property property is also important.了解Page.IsPostBack Property属性也很重要。
Gets a value that indicates whether the page is being rendered for the first time or is being loaded in response to a postback.
获取一个值,该值指示页面是第一次呈现还是正在加载以响应回发。
To understand that better, put a breakpoint inside the code written below为了更好地理解这一点,请在下面编写的代码中放置一个断点
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
// excecutes on page load
}
else
{
// executes on button click
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.