How postback works in ASP.NET
Introduction
In this article, we will take a closer look at how ASP.NET pages post back to themselves, and how to customize this feature in our web applications.
function __doPostBack(eventTarget, eventArgument)
One of the most important features of the ASP.NET environment is the ability to declare controls that run on the server, and post back to the same page. Remember the days of classic ASP? We would create a form which would accept the user's input, and then we would most probably have to create another page that would accept all those inputs, either through HTTP GET or POST, and perform some kind of validation, display and action. Sometimes, even a third page was necessary to perform our actions. This wasted a lot of time and complicated things when you had to make a change. But of course, this is not necessary any more with ASP.NET. There is no need to create second pages that accept the inputs of the first, process them and so on. Form fields and other controls can be declared to run on the server, and the server simply posts the page back to itself and performs all the validation, display and actions. Our life as web developers has become a million times better. But how exactly is this done?
When a control is declared to run on the server, a VIEWSTATE is created which remembers the ID of that control, and the method to call when an action is performed. For example, let's say we input this HTML on a page:
1
<script language="VB" runat="server">
2
Sub Test_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
3
'enter your code to perform
4
End Sub
5
</script>
6
<html>
7
<body>
8
<form runat="server" id="myForm">
9
<asp:linkbutton id="Test" runat="server" text="Create Text file" onclick="Test_Click" />
10
</form>
11
</body>
12
</html>
&n
Ïà¹ØÎĵµ£º
//private string datapatch = ConfigurationSettings.AppSettings["acessconn"];//Êý¾Ý¿âµØÖ·
private string datapatch = "db/global.asa";//Êý¾Ý¿âµØÖ·
///
/// È¡µÃdataset
//
/// ²éѯÓï¾ä
///
public DataSet GetDataSet(string Commandtext)
{&nbs ......
² Oracle9iµÄ°²×°£¬Çë²ÎÕÕ¹Ù·½µÄ°²×°ËµÃ÷¡£
² Oracle9i°²×°³É¹¦ÒÔºó£¬Ê¹ÓùÜÀíÔ±£¨Óû§Ãû£ºsys¡¢ÃÜÂ룺sys£©µÄÉí·ÝµÇ¼½øÈ¥£¬´´½¨Ò»¸öÓû§ddymis£¬ÃÜÂ룺ddymis,½ÇɫĬÈϸ³Óèdba¡£
² ......
ÔÚ.Netƽ̨ϽøÐÐCSÈí¼þ¿ª·¢Ê±,ÎÒÃǾ³£Óöµ½ÒÔºó»¹ÒªÓõ½Ä³Ð©±äÁ¿ÉÏ´ÎÐ޸ĺóµÄÖµ,ΪÁ˼òµ¥Æð¼û,ºÜ¶àÈ˶¼Ï°¹ßÓÃstaticÀ´¶¨ÒåÕâЩ±äÁ¿,ÎÒÒ²ÊÇ¡£ÕâÑù·Ç³£·½±ã£¬ÏÂÒ»´Îµ÷ÓÃij¸öº¯Êýʱ¸Ã±äÁ¿ÈÔÈ»±£´æµÄÊÇ´¦Àí¹ýµÄÖµ£¬Ö±½ÓÄÃÀ´ÓþͿÉÒÔÁË¡£
ÏÖÔÚתÈëÁËBSÈí¼þ¿ª·¢£¬ÎÒÃǺÜ×ÔÈ»µØ»áÑØÓ ......
ÔÚ×î½üµÄÓÃasp.net ¿ª·¢µÄÏîÄ¿ÖУ¬×öÓÅ»¯£¬Òª°ÑÒ³Ã澲̬»¯£¬²éÁ˺ܶàÖÖ·½·¨£¬×îºóÑ¡ÔñÁËÓÃÄ£°åÀ´ÊµÏÖ£¬
×îÖÕÒ³µÄʵÏֱȽϼòµ¥£¬ÔÚÍøÉÏÕÒÁËÒ»¶Î´úÂ룬µ«Ê×Ò³£¬¶þ¼¶Ò³£¬ÁбíÒ³µÄ´¦Àí±¾ÈËÊÇÓõÄÒÔÏ·½°¸£¬ÏÖÔÚ»¹Ö»ÊÇÒ»¸ö±È½Ï¼òµ¥µÄ£¬Ï£ÍûÓдó¼Ò¶à¶àÖ¸µã£¬½»Á÷£»
·½·¨ÈçÏ£º
˼·ÃèÊö£º
1£ ......