page-lifecycle

C# Clear Session

99封情书 提交于 2019-12-17 10:26:09
问题 Question #1 I want to know when am I supposed to use: Session.Abandon() // When I use this during tracing and after calling it- I find the session still has a value. And when am I supposed to use : Session.Clear() When should I use each specific method? In general? In my specific case? I check if session is not equal null in Page Load. If session is equal to null, I wanna to clear session and redirect to the login page? Should I use something like this: private void initSession() { Session

ASP.NET Life-cycle Dichotomy: Dynamically Added Controls and Events

不羁的心 提交于 2019-12-13 02:53:05
问题 The situation: I have user controls with buttons that have hooked events. Controls with events need to be initialized in Page_Load or earlier. I wish to spawn these user controls dynamically by clicking an Add button. It is important to remember that events, such as click events, are not fired until just before Page_LoadComplete. Broken Solution A: Page_Load: Dynamically create an Add button, hook click event. User clicks on the Add button, triggers postback. Page_Load: Creates the Add button

Object reference not set to an instance of an object when tring to set the selection of a combo box

感情迁移 提交于 2019-12-12 13:34:28
问题 I have a text box and a RadComboBox like this : <asp:TextBox ID="txt_inner_emp_num" runat="server" Width="60px" ontextchanged="txt_inner_emp_num_TextChanged" AutoPostBack="true"></asp:TextBox> <telerik:RadComboBox ID="rad_ddl_inner_emp_name" runat="server" CausesValidation="False" CollapseDelay="0" Culture="ar-EG" ExpandDelay="0" Filter="Contains" ItemsPerRequest="100" MarkFirstMatch="true" Width="380px" EnableAutomaticLoadOnDemand="True" EmptyMessage="-emp name-" ShowMoreResultsBox="True"

Should I wait for ajax to complete to redirect a page?

廉价感情. 提交于 2019-12-12 10:46:55
问题 I know how to wait for ajax to complete, but if I'm going to redirect a page after some ajax calls are fired off, should I wait for them to complete before the redirect? Does it matter? 回答1: If you're confident that the ajax call will be successful, then once the ajax call has occurred, redirecting won't affect it as far as your server is concerned. But don't forget, the client could lose their connection or a number of errors could occur, so you should probably wait to make sure the calls

ASMX equivalent of Page_Init?

给你一囗甜甜゛ 提交于 2019-12-12 08:26:04
问题 I have some code I would like to execute very early in the lifecycle of a call to an ASMX function. For our ASPX pages, this code is in the Page_Init() function on a base class, from which all our ASPX pages inherit. Is there an ASMX equivalent to the ASPX's Page_Init() function? Better yet, is there an ASMX lifecycle diagram like the ASPX one? http://msdn.microsoft.com/en-us/library/ms178472.aspx If there is an ASMX equivalent to Page_Init(), I assume I can implement code in a common base

Asp.net page life cycle error, [duplicate]

你说的曾经没有我的故事 提交于 2019-12-12 01:23:05
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: how to call a javascript fn in Update panel on Partial postback in asp.net update panel is doing partial post back, and I have a Timer_Tick method where I call the method to do data binding and updatepanel onLoad for some calculation for graph. I use a Javascript to draw the graph window.onload = function () { r.init(); }; SO the graph is displayed when the page loads, when the update panel updates after 4

ASP.Net: How to stop page execution when browser disconnects?

試著忘記壹切 提交于 2019-12-11 11:02:32
问题 If a browser requests an ASP.Net page and then the user clicks "stop" or navigates away, I though that the browser would close the connection and ASP.Net would perhaps stop execution. I don't think that's the case since Dispose() is not called when I test this. Is there anyway to know when the browser/client has disconnected and then stop the page from executing? 回答1: You can check the IsClientConnected if (!Response.IsClientConnected){ HttpContext.Current.Response.End(); return; } 来源: https:

Ddynamic GridView with TemplateFields - confusion in LifeCycle

眉间皱痕 提交于 2019-12-11 09:00:31
问题 I have a databound gridview that I create dynamically. The datasource returns an object based on the several DropDownLists (types of objects are different). Depending on the type of the object, the GridView must display certain fields specific only for the object. Also, there is a DropDownList whose SelectedValue decides which columns of an object will be added/excluded from the GridView. Here is a method that creates the GridView (I write in VB.NET but C# is also very welcome): Private Sub

ASP.Net Object Data Source - Data Binding

会有一股神秘感。 提交于 2019-12-11 07:48:40
问题 At what point does a ASP.Net Object Data Source bind data, from the specified data source, in the page life cycle? 回答1: From the Page Life Cycle Overview, referring to the databinding event: This event is raised by data-bound controls before the PreRender event of the containing control (or of the Page object) and marks the beginning of binding the control to the data. And regarding the DataBound event: This event marks the end of data-binding operations in a data-bound control. In a GridView

Can I fire button click event without firing pageload event?

99封情书 提交于 2019-12-11 05:51:37
问题 I have a button on my page and and few textboxes which alters their context on page_load event. when I open the page for the first time it loads random data from a database to textboxes with a function in pageload and also I create those textboxes dynamically. what I want is to make some changes on textboxes texts and click the button than send new context of textboxes to database. But when I click on button, PageLoad event fires again and It regenerates the textboxes and the context of them