Tuesday, September 17, 2013
In this blog, I will go over how you can simulate a button click postback. By using the RaisePostBackEvent() method. Many of you probably want to do this because you wanted to refresh your GridView by faking a postback. As you will see the two methods presented on this blog does not perform an actual postback, even though it behaves like it does.
Mark Up
Code Behind
After you run the code you will find out that both ways of doing this does not cause a post back event.
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.
Subscribe to:
Post Comments (Atom)
Search This Blog
Tags
Web Development
Linux
Javascript
DATA
CentOS
ASPNET
SQL Server
Cloud Computing
ASP.NET Core
ASP.NET MVC
SQL
Virtualization
AWS
Database
ADO.NET
AngularJS
C#
CSS
EC2
Iaas
System Administrator
Azure
Computer Programming
JQuery
Coding
ASP.NET MVC 5
Entity Framework Core
Web Design
Infrastructure
Networking
Visual Studio
Errors
T-SQL
Ubuntu
Stored Procedures
ACME Bank
Bootstrap
Computer Networking
Entity Framework
Load Balancer
MongoDB
NoSQL
Node.js
Oracle
VirtualBox
Container
Docker
Fedora
Java
Source Control
git
ExpressJS
MySQL
NuGet
Blogger
Blogging
Bower.js
Data Science
JSON
JavaEE
Web Api
DBMS
DevOps
HTML5
MVC
SPA
Storage
github
AJAX
Big Data
Design Pattern
Eclipse IDE
Elastic IP
GIMP
Graphics Design
Heroku
Linux Mint
Postman
R
SSL
Security
Visual Studio Code
ASP.NET MVC 4
CLI
Linux Commands
Powershell
Python
Server
Software Development
Subnets
Telerik
VPC
Windows Server 2016
angular-seed
font-awesome
log4net
servlets
tomcat
AWS CloudWatch
Active Directory
Angular
Blockchain
Collections
Compatibility
Cryptocurrency
DIgital Life
DNS
Downloads
Google Blogger
Google Chrome
Google Fonts
Hadoop
IAM
KnockoutJS
LINQ
Linux Performance
Logging
Mobile-First
Open Source
Prototype
R Programming
Responsive
Route 53
S3
SELinux
Software
Unix
View
Web Forms
WildFly
XML
cshtml
githu
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