page-lifecycle

How to update page data after event handling?

我们两清 提交于 2019-12-01 07:02:31
问题 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

Best way to intercept a Button postback

蓝咒 提交于 2019-12-01 05:11:55
I've seen other solutions like this one which is pretty straightforward but what if the javascript function does more than just confirm('sure?'); ? I never know when it will return a bool. So I've decided to implement all my ASP.NET Buttons like this: <button id="btnDelete" name="btnDelete" class="btn">Delete</button> <asp:Button ID="_btnDelete" runat="server" OnClick="_btnDelete_Click" style="display:none;" /> $('#btnDelete').click(function (e) { $.blockUI({ message: $('#divConfirmDeleteModal'), overlayCSS: { cursor: 'default' }, css: { cursor: 'default' }, baseZ: 5555 }); return false; }); $

Loading Nested UserControls in ASP.NET

我的未来我决定 提交于 2019-12-01 01:59:43
I've got an issue with nested controls not loading properly. I've tried various page methods and nothing seems to work. EDIT: The site compiles and runs fine--it just leaves a blank screen though. Basically I have a wrapper control for a Chart that allows me to select data, bind, and customize the chart with a lot of abstraction. I need another wrapper control for that because there may be groups of charts that I want to represent easily. Generalized answers would be great too. Here's what I have. I've replaced my custom properties/attributes with fillers: Default.aspx: <%@ Page Language="C#"

Check Session variable and Redirect to login page before page load

不羁岁月 提交于 2019-12-01 01:49:16
How can I check a variable and redirect to another page before the page loads using ASP.NET? I'm aware of the life cycle, and PageInit() sounds like it would be right, but I can't seem to find anywhere to put the code without and error within Visual Studio. I can't put the onpageinit="" within the first line of my page declaration. Am I suppose to put it somewhere different? My page declaration looks like: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="dashboard.aspx.cs" Inherits="dashboard" MasterPageFile="~/Design.master" %> This is the code that I want to run on the page load: //

Check Session variable and Redirect to login page before page load

坚强是说给别人听的谎言 提交于 2019-11-30 21:05:49
问题 How can I check a variable and redirect to another page before the page loads using ASP.NET? I'm aware of the life cycle, and PageInit() sounds like it would be right, but I can't seem to find anywhere to put the code without and error within Visual Studio. I can't put the onpageinit="" within the first line of my page declaration. Am I suppose to put it somewhere different? My page declaration looks like: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="dashboard.aspx.cs" Inherits=

How to Execute Page_Load() in Page's Base Class?

心不动则不痛 提交于 2019-11-30 10:58:34
问题 I have the following PerformanceFactsheet.aspx.cs page class public partial class PerformanceFactsheet : FactsheetBase { protected void Page_Load(object sender, EventArgs e) { // do stuff with the data extracted in FactsheetBase divPerformance.Controls.Add(this.Data); } } where FactsheetBase is defined as public class FactsheetBase : System.Web.UI.Page { public MyPageData Data { get; set; } protected void Page_Load(object sender, EventArgs e) { // get data that's common to all implementors of

Do I need to unsubscribe from (manually subscribed to) events in asp.net?

僤鯓⒐⒋嵵緔 提交于 2019-11-30 09:16:24
问题 Do the same best practis rules regarding subscribing/unsubscribing to events apply in asp.net? I know it might seem like a silly question, but when I think about it, I have never really seen any code where people first subscribe to an event on a page and then unsubscribe later on in the web request. Example 1: On a page, in the Page_Load method, I subscribe to a updating event on a ListView. Should I unsubscribe from that event later on, for example in the OnPreRenderComplete method? Example

How to detect page refresh in .net

好久不见. 提交于 2019-11-30 08:29:51
I have a Button_click event. While refreshing the page the previous Postback event is triggering again. How do I identify the page refresh event to prevent the Postback action? I tried the below code to solve it. Actually, I am adding a visual webpart in a SharePoint page. Adding webpart is a post back event so !postback is always false each time I'm adding the webpart to page, and I'm getting an error at the else loop because the object reference is null . if (!IsPostBack){ ViewState["postids"] = System.Guid.NewGuid().ToString(); Cache["postid"] = ViewState["postids"].ToString(); } else{ if

How to Execute Page_Load() in Page's Base Class?

ⅰ亾dé卋堺 提交于 2019-11-29 22:57:00
I have the following PerformanceFactsheet.aspx.cs page class public partial class PerformanceFactsheet : FactsheetBase { protected void Page_Load(object sender, EventArgs e) { // do stuff with the data extracted in FactsheetBase divPerformance.Controls.Add(this.Data); } } where FactsheetBase is defined as public class FactsheetBase : System.Web.UI.Page { public MyPageData Data { get; set; } protected void Page_Load(object sender, EventArgs e) { // get data that's common to all implementors of FactsheetBase // and store the values in FactsheetBase's properties this.Data = ExtractPageData

In ASP.Net, during which page lifecycle event does viewstate get loaded?

时光怂恿深爱的人放手 提交于 2019-11-29 20:19:57
I know it happens sometime before Load, but during what event exactly? It's loaded into memory between init and load. See t his article for a full break down of the page lifecycle. I once got into this question too and got my answer from TRULY understanding Viewstate article, which I highly recommend. After reading it I designed a graphic that helped me to understand better what was happening on between each stage and when and how ViewState was doing its job. I'd like to share this graphic with other people that (like myself) need to see how stuff work in a more visual way. Hope it helps! :)