Forcing Child / Container Events To Fire Before Parent Onload?

May 12, 2010

I'm working on a questionnaire type application in which questions are stored in a database. Therefore, I create my controls dynamically on every Page.OnLoad.This works like a charm and ViewState is persisted between postbacks because I ensure that my dynamic controls always have the same generated Control.ID.

In addition to the user control that dynamically populates the questions, my questionnaire page also contains a 'Status' section (also encapsulated by a user control) which represents the status of the questionnaire (choices are 'Complete', 'Started' or 'In Progress'). If the user changes the status of questionnaire (i.e. from 'In Progress' to 'Complete'), I need to postback to the server because the contents of the dynamic portion of the questionnaire depend on the selected status.

Some questions are always present regardless of status, and yet others may not be present at all for the selected status. The point is, when the status changes, I have to postback to the page and render the right set of questions. Additionally, I need to preserve any user entered values for those questions which are 'always available'.

However, due to the page life cycle in ASP.NET, the 'Status' user control's OnLoad, which contains the correct status needed to load the right questions from the DB, doesn't get executed until after the 'dynamic questions' user control has already been populated (with the wrong/stale values).

To get around this, I raise an event from my 'Status' user control to the main page to indicate that the Status has changed. The main page then raises an event on the 'dynamic questions' user control. Since by the time this event bubbles up, the 'dynamic questions' user control has already loaded the 'wrong' questions from the DB, it first calls Controls.Clear. It then happily uses the new status to query the database for the 'correct' questions and does a Control.Add() on each. FYI, Control.IDs are consistent across postbacks.

This solution works...sorta. The correct set of questions for the selected status do get rendered; however ViewState is getting lost for those 'always available' questions. I'm guessing this is because the 'dynamic questions' user control calls Controls.Clear when responding to the status changed event. This must somehow kill the association between ViewState and my dynamic controls, even though the Control.IDs are consistent.

This seems like such a common requirement, I'm virtually certain there is a better, cleaner and less error prone approach to accomplish this. In case its not plainly obvious, I haven't been able to grok the ASP.NET page life-cycle despite working with it for the last year.

View 4 Replies


Similar Messages:

Web Forms :: Fire Parent Button Event From Child

May 7, 2010

I have parent form in which i have two buttons. button1 and button2. By clicking on button1 a model popup widow shows. In popup window i have a button like button3 what i need that by cliking on button3 on popup page i want to fire button2 event on parent page and close popup page.

View 1 Replies

Javascript - Reporting Child Window's Events To Parent Window To Reset Timer Value Of User Timeout Code

Sep 2, 2010

I've got a Jquery function that I wrote which blacks out the screen after a certain amount of inactivity, creates a pop-up that allows the user to click a button to stay logged in, and logs them out (closing the application window) if they do not respond in time.

The environment is ASP.NET (VB). We don't technically use master pages, but we do have a parent page in which our header, footer and nav reside, and my Jquery code is called from that window, loaded via an IFrame.My problem is that if one is working in a child window, the parent window doesn't recognize that the system is in use, and will automatically engage at the allocated time.I've tried everything under the sun I can think of and nothing works properly. My event handler is working, and it does call the parent window function, but the timer is not being reset.

I have this function in the parent window:

<script language="javascript" type="text/javascript">
function window.reportChildActivity() {
SESSION_ALIVE = true; [code]....

View 1 Replies

5 Cascading Dropdowns (Parent To Child And Child To Parent)?

Aug 26, 2010

Simple and blunt: my cascading dropdownlists clear when a postback occurs. Does anyone know a quick way around that?For more information, read on...

I have 5 dropdown lists that define a training class location and line of business: Site, Parent Client, Client, Program, Project I'm trying to build cascading dropdownlists that can work from any direction (i.e. select a site and all other lists are filtered by site...select a project and all other dropdown lists are filtered by project). I've built the SQL Select statement behind the lists that filters (accurately).

View 3 Replies

Web Forms :: How To Raise Event On Usercontrol From Onload Events

Jan 7, 2010

I have a login.ascx control with three controls (LoginName, Password and btnLogin) , I want to rase a click event on this button from .aspx page because some restriction is there so that I am unable to write any code on .ascx page.I am bale to put loginName and password on .ascx by using query string but unale to raise event.

[Code]....

View 1 Replies

Web Forms :: Parent-child Web Form: How To Close Dialog Box And Return Values To Parent Form?

Jan 24, 2010

In my website I have two forms: parent form and child form(dialog box). Their expected behaviour is like this: if clicked on 'show' button on parent form, a dialog form opens that displays a gridview. In dialog form, if clicked on 'select' button it closes
itself and returns value in selected row back to parent form.

To achieve this I write following code (.cs) : in parent form:

void ShowBtn_Click(object sender, EventArgs e)

{

StringBuilder jScript = new StringBuilder(); [code]....

Now problem is: the code in parent .cs works fine, it opens the dialog properly. But when clicked on 'select', instead of returning back to parent, it opens the same dialog again in new window. This newly open window says "Done but error on page" at left bottom.

View 6 Replies

AJAX :: Fire Link Button Event In Tab Container?

Apr 6, 2010

how to fire a link button event which is there at ajax tab container?

View 1 Replies

Accessing SiteMapNode Container.DataItem From Outside Of Parent Repeater?

Feb 13, 2010

I am trying to access the current 'active' top level node from a sitemap repeater from outside of the ASP.NET repeater used to render it, this is for CSS styling purposes as I want to place the child nodes on the subsequent row with different styling horizontally. At present I have the following code which I can't get to display correctly using CSS.

[code]....

I would like to display the child nodes on the next light blue element which I can do perfectly well from a seperate div if this was not rendered using a child repeater. In the image below Blog and Services are top level nodes and their subseqent nodes (2 for each) should be displayed on the light-blue row below. Is this possible?

View 2 Replies

Web Forms :: Accessing Properties Of A Parent/container Page From User Control?

Jan 31, 2011

i am using .net 2.0 for developing my web app. want to modify a public property in the container page. how do i access the containser page?

[code]....

View 1 Replies

Possible To Refresh Parent Page From Child's Child Page Using Javascript?

Apr 26, 2010

Is it possible to refresh parent page from child's child page using javascript.

I have a webform which opens a child window, a button on child window closes the present child window and opens a subchild window. Now a button on subchild should close the window and refresh the parent form.

[code]....

View 3 Replies

How To Fire Innergridview Events

Feb 17, 2011

I have one main gridview and child gridview.It showing all questions. for every question i have another gridview to show answer options.If i want to delete one answer option how can i delete?

View 1 Replies

C# - Events Doesn't Fire When Using UpdatePanel

Jun 8, 2010

What I did is, I have made 2 user controls. One control is inside the other.

NoW one control has a buttton and a data grid and datalist in it. When pressing button I am filling datagrid while datalist visiblity false. This is working fine. But now when I press some link button in datalist data, it should call item_command event but it is not calling.

I have also used a Updatepanel as a wrapper(all controls are inside it).

View 1 Replies

Control Events Failing To Fire?

Feb 17, 2011

I have a Page that does a LoadForm("blah.ascx"). The Page does have a ModalPopupExtender on it (It was on the ascx originally but I moved it to the Page as a test, doesn't work either way). There is a Loop here so the LoadControl() will be called multiple times and will put multiple instances of the ascx on the Page.

Blah.ascx has some buttons on it but when I click the buttons the click event does not fire and the Page gets reloaded without the control on it anymore.

The Page.Page_Load event does fire. And yes, I have the LoadControl() inside an Not IsPostback check. Just the controls events, including Page_Load, do not fire on postback, only on initial load.

View 6 Replies

The Best Way To Fire Events From Classes Within The Solution With A Timer?

Mar 22, 2010

A group I am in at school is developing a website for a client. It needs to be able to send weekly emails out to all users, as well perform many other scheduled tasks.My question is: what is the best way to fire events from classes within the solution with a timer? I've read that a Windows Service can be used...?

View 2 Replies

AJAX :: Events Don't Fire In Async Postbacks

Feb 16, 2010

So I have a page with an UpdatePanel and some controls in there. When I explicitly type/copy+paste the page's address into the address bar, let VS navigate there for me, or follow a link to the page, all of the AJAX works fine. But if I refresh this page, the JS on the page initiates the async postback, but the appropriate event is never called on the server (although Page_Load is) and the client never recieves the markup sent back by the server. This issue seems to be limited to Firefox 3.6 (Gecko build 1/15/2010)(doesn't happen in IE8). I have yet to try on other versions of Firefox.

View 2 Replies

Custom Controls Don't Fire Correct Events?

Jun 30, 2010

I'm building a library of custom controls. My controls are inherited from CompositeControl. Depending on the user's answer I have to insert more custom control. I have a PlaceHolder (_ph) passed in from the client code. I insert my controls into that PlaceHolder.

My problem is the control I inserted in the event handler does not fire its event, but it fires the parent event. For example, if I have an EddDropDown A, and the user picks an answer, I have to create EddDropDown B and C in edd_SelectedIndexChanged. When I pick an answer for B, it fires SelectedIndexChanged for A instead of B.

I think it has something to do with entering the page cycle late.

this is an example of my controls:

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

[Code]....

View 1 Replies

C# - Fire Events And Methods Automatically -according To A Schedule?

Dec 20, 2010

Well, I'm sure this is not the first time to see this question. and TBH you can find this question answered on many other websites and blogs -not only here-

But I never saw a complete answer for this question, I mean no one talked about the advantages and the disadvantages. no one shared a real experience.

Although Quartz.NET seems like a good solution but yet, there's no enough reviews or a good comparison between the different ways to achieve such a thing.

As far as I read about it I found this are the possible ways of doing this :

Using a: Web Service, Windows Appliction, Console Application, Quartz.NET.

Examples of stuff I want to achieve with the scheduled or automatic methods/events are like archiving after a certain period, auto deleting/moving records in the database, setting a property of an object after a certain time, automatically run some methods according to my holiday schedule.

I hope you'd share your experience either with one of those approaches or share a new way of doing this.

View 4 Replies

CreateChildControls Method ChildControls Do Not Fire Events?

Mar 22, 2011

I have created a custom web control. In that control on CreateChildControls method i dynamically create a Table add rows to it which contains a ImageButton and i am trying to attach an event to this ImageButton but the event never fires?

I tried on Init method too it does not work . The code goes like this on CreateChildControls

I create a Panel . The i create a table with data and an imagebutton on it I add this table to the created panel I add this Panel to the Controls.Add method.

I have also observed that if i add a control directly to the Controls.Add() method and attach an event it works fine .

Meaning ,

1. Create a button attach an event handler

2. Add to the Controls.Add() method

On doing the above it works fine . Only the child controls events do not get fired is there anything that i am missing ??

View 1 Replies

Applying Events Handler To Child Elements?

Jan 11, 2010

Edit : Problem wasn't related Event Propagation, if you want to know how to stop propagation in jQuery, then use event.stopPropagation();

When user moves his/her mouse over <span> element my jQuery code appends an <img>into this <span> element and when he moves out his mouse off <span> than the element appended is removed. It helps people to edit the field when clicking on the appended <img> element.

The reason I used append() method to add <img> into <span> is because I want to keep <img> element visible when user moves his mouse over to appended <img> element (<img> is becoming <span>'s child element) But it didn't happen and when user moves his mouse over it <img> is being deleted. I am thinking it is because event propagation but I couldn't find how to activate it in jQuery as we do with addEventListener in Firefox based browsers.

JQuery Code :

$(document).ready(function() {
$('.EditEnabled').bind("mouseover", ShowEditFields);
$(".EditEnabled").bind("mouseout", HideEditFields);
});
function ShowEditFields(event) {
$(event.target).append(" <img id='editImg' src='images/edit.png' style='margin-bottom:-3px'/>");
}
function HideEditFields(event) {
$(event.target).children("#editImg").remove();
}

Simple HTML :

<span id="something" class="EditEnabled">Something Here</span>

View 3 Replies

Child UpdatePanel And Parent UpdateProgress

Nov 23, 2010

I have a nested child and parent UpdatePanel. The problem is, when the child UpdatePanel is refreshed/posted, the UpdateProgress in parent fires up. How can I prevent this? The structure is like this:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate></ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate></ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:UpdateProgress ID="UpdateProgress3" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
<ProgressTemplate></ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>

When UpdatePanel2 is posted, UpdateProgress3 is not displayed but UpdateProgress1 and UpdateProgress2 are. What should I do?

View 1 Replies

Looping Through Parent Child Combination Xml Using C#?

Dec 7, 2010

I am new to xml, i want to looping through the below xml and save the records in the database. the below xml is parent child combination, parts as to be saved under respective parents. if the source field is M then there will be child item for that.

<PARENT>
<COMPONENT>
<part>test1</part><source>M</source><ParentPart>parent</ParentPart>

[code]...

View 1 Replies

Sharing Value From Child To Parent Control?

Oct 11, 2010

In asp.net, I have a parent and a child control. Within the child control I have a dropdown list. Based on dropdown list's selected value I would like to toggle Visibility of Panel in parent control. For instance if I select Show in child control dropdown list, I need to pass true to parent control to make Panel visible and vice versa. How should I do that. I have read that can be done via the event handling and have seen certain scenarios but I am not clear on that.

View 3 Replies

MVC :: Working With Parent Child Entities?

Sep 22, 2010

i am working on POCO entities. i had a requirement to provide Edit feature for parent and respective Child records in single View.

Eg: Parent-Customer, Child-Order tables

when updating the parent entity by using => UpdateModel(CustomerIns);

and updating the child entity by using => TryUpdateModel(CustomerIns.Order, "Orders");

The Child Controls Names are like Orders[0].OrderID,Oders[0].OrderDate,etc

The Parent and Child Entities are updating when UpdateModel() is called but when saving Changes by calling Context.SaveChanges() i am getting exception like:

"The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted."

View 3 Replies

C# - Change XML Child Element Into Parent?

Jul 8, 2010

I have an xml document that has a structure like so:

<?xml version="1.0" encoding="iso-8859-1" ?>
- <newdataset xml="version="1.0" encoding="iso-8859-1"">
- <officelist>
<officeid>2</officeid>
<office>Office</office>
<region>BC</region>

I would like to have the office id = 2 to be its own element. Like so

<?xml version="1.0" encoding="iso-8859-1" ?>
<newdataset xml="version="1.0" encoding="iso-8859-1"">
<officelist>
<officeid id=2/>
<office>Office</office>
<region>BC</region>
</officeid>
</officelist>
</newdataset>
xmlDS += offices.GetXml();
xmlDS = xmlDS.Replace(@"xml:space=""preserve""", " ");
XmlDocument doc = new XmlDocument();
XmlNode declaration = doc.CreateNode(XmlNodeType.XmlDeclaration, null, null);
doc.LoadXml(xmlDS);
doc.Save(Response.OutputStream);

That is my code so far... not sure how to set a child node to become a parent node

View 1 Replies

AJAX :: Two Modalpopups As A Parent-child?

Aug 25, 2010

When I open two modalpopups, one over another, there is unexpected order.After click on "Open Parent Panel", and click on "Open Child Panel",Child Panel (newone) is under the Parent. [URL=http://img820.imageshack.us/i/un1f.jpg/][IMG]http://img820.imageshack.us/img820/5836/un1f.jpg[/IMG][/URL]Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]What should I do to get it in "normal order"?The code is:

<asp:ScriptManager ID="A" runat="Server">

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved