Mark Up
<form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </div> </form>
Code Behind
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication2 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { this.RaiseEvent(this, new EventArgs()); if (!Page.IsPostBack) { this.Button1_Click(this, new EventArgs()); } } protected void RaiseEvent(object sender, EventArgs e) { this.RaisePostBackEvent(Button1, " "); } protected void Button1_Click(object sender, EventArgs e) { Response.Write("You've clicked " + Button1.Text + " "); if (Page.IsPostBack) { Response.Write("this is a post back"); } else if (!Page.IsPostBack) { Response.Write("this is not a post back"); Response.Write("<br/>"); } } } }
After you run the code you will find out that both ways of doing this does not cause a post back event.
Liên hệ Aivivu, đặt vé máy bay tham khảo
ReplyDeletemua ve may bay di my
vé máy bay từ mỹ về việt nam bao nhiêu
chuyến bay thương mại từ canada về việt nam
mở chuyến bay từ nhật về việt nam
mua ve may bay tu han quoc ve viet nam
Vé máy bay từ Đài Loan về Việt Nam
ve may bay chuyen gia nuoc ngoai sang Viet Nam