page-lifecycle

Is it acceptable to keep a db connection open for the life of the page?

感情迁移 提交于 2019-12-04 03:31:23
问题 Everybody knows that you should close a connection immediately after you finish using it. Due to a flaw in my domain object model design, I've had to leave the connection open for the full page life cycle. Essentially, I have a Just In Time property which opens a connection on first call, and then on Page.Unload (..) it would check if a db connection was ever open, and then close it if it was. Since it only takes a second, I’ve had the opinion its not too much different than closing it

JSF - Another question on Lifecycle

瘦欲@ 提交于 2019-12-03 21:41:49
Today I'd like to know some features on the JSF Lifecycle. Let me start : 1 - Phase 2:Apply request Values - During this phase,each component in the view will search for its values in the request and set the new values to them Uhm, ok nice. So, the View will be built due to the previous Beans parameters. After, there is a partial View, generated with the request values. (Right? Later, in the 3° phase, they will be compared) . But, for example, if a values in the request list is absent during the creation of this last view? Values will be null? 2 - Phase 5: Invoke Application - Once all the

ASP.NET: What happens to code after Response.Redirect(…)?

倖福魔咒の 提交于 2019-12-03 10:29:49
问题 Does Response.Redirect() cause the currently running method to abort? Or does code after Response.Redirect() execute also? (That is, is it necessary to return/Exit Sub after a Response.Redirect?) 回答1: This may not be a complete answer, but from what I've seen... Response.Redirect does, actually cause the code to stop executing by throwing a System.Threading.ThreadAbortException. You can see this for yourself by setting up global error handling in the Global.Asax and testing a Response

Dynamic Event Handler not Firing

戏子无情 提交于 2019-12-01 23:17:14
问题 I want to create an amount of controls dynamically based on a number the user enters into a textbox. This part I have working fine, but I also need the dynamically created textboxes to have event handlers of their own, so the user can enter a number into them, and have more controls created. My problem is that the event handler I've setup for these controls to use does not fire. Maybe I'm not understanding the ASP.NET page life cycle correctly, but I am currently having the dynamic controls

How can page events be handled from a usercontrol? (VB.net)

让人想犯罪 __ 提交于 2019-12-01 22:28:08
问题 I would like some code to execute at the "preload" stage of my usercontrol's lifecycle. However the preload event is only available on the Page object. So, I added the following method to my usercontrol: Private Sub Page_PreLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Page.PreLoad However, I know get the compile error: "Handles clause requires a WithEvents variable defined in the containing type or one of its base types" As the Page property is inherited from UserControl

ASP.NET event order during postback or initial request

…衆ロ難τιáo~ 提交于 2019-12-01 21:51:12
Could I get some confirmations from the community that I'm not going mad, and that the life cycle of a page during post back is in deed in a different order to when the page is initally requested. If this is the case pointers towards references/articles outlining the order would be greatly appreciated. (A postback equivalent of the page life cycle image would be great) The behaviour is slightly different but the order is the same. In this respect "Postback" is essentially a state flag on the request. http://msdn.microsoft.com/en-us/library/ms178472.aspx (nice image btw) edit: thinking about it

Is it acceptable to keep a db connection open for the life of the page?

匆匆过客 提交于 2019-12-01 18:13:40
Everybody knows that you should close a connection immediately after you finish using it. Due to a flaw in my domain object model design, I've had to leave the connection open for the full page life cycle. Essentially, I have a Just In Time property which opens a connection on first call, and then on Page.Unload (..) it would check if a db connection was ever open, and then close it if it was. Since it only takes a second, I’ve had the opinion its not too much different than closing it immediately. Is this ok? Or should it still be closed immediately after every single use? Thanks in advance.

Closing a conneciton in the “unload” method

◇◆丶佛笑我妖孽 提交于 2019-12-01 17:45:18
I have inherited a web framework whereby the previous developer has opened and closed his database connections in the init/unload methods of the page life cycle. Essentially constructor is like this (simplified to demonstrate the point); public class BasePage { protected DBConnection _conn; public BasePage() { Init += StartConnection; Unload += EndConnection; } private void StartConnection(object sender, EventArgs e) { _conn = new DBConnection(Application["connectionstring"].ToString()); } private void EndConnection(object sender, EventArgs e) { if (_conn == null) return; if (_conn.Connection

Closing a conneciton in the “unload” method

馋奶兔 提交于 2019-12-01 17:27:15
问题 I have inherited a web framework whereby the previous developer has opened and closed his database connections in the init/unload methods of the page life cycle. Essentially constructor is like this (simplified to demonstrate the point); public class BasePage { protected DBConnection _conn; public BasePage() { Init += StartConnection; Unload += EndConnection; } private void StartConnection(object sender, EventArgs e) { _conn = new DBConnection(Application["connectionstring"].ToString()); }

How to update page data after event handling?

大憨熊 提交于 2019-12-01 09:03:42
On Page_Init I create a table of dynamically created controls based on a couple of database tables. One of the controls is an ImageButton for moving an list item up the list. What this event handler does is to update the SortOrder column in the database for the affected items. Now the problem is that since the controls are created in the Page_Init event and the SortOrder is updated later on when the ImageButton command event is fired. What's the best procedure for updating the table with the correct SortOrder. If I recreate the table after the event has fired the ImageButton command event does