Hello All,
Here is my scenario:
I am using VS2010 and have a ASP.NET web application. On my page I am using a WebUserControl that uses a modelpopupextender to allow a user to select contacts from a list. All of this is contained in a asp.net formview.
After a user selects some contacts they click the submit button and their selection goes to a ListView that is bound to a DataTable that I store in the session.
All of the above works great.
The problem is that when the user inserts the object with the contacts the DataTable information is kept and if you do another insert the previous objects re-appear when they should not. I can't clear the session after the insert incase the user closes the page without inserting and another open retains the session or another screen re-loads the data.
What I want to do is the following:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
ClearSessionDataTable();
if (AccountID == 0)
{
this.fvAccount.ChangeMode(FormViewMode.Insert);
}
}
But...... the load says that it is not a postback no matter what button I click on the page. So the session information is cleared at every event. Also the Viewstate is not kept between postbacks.
What I need is a way to determine the initial load of the page so I can clear the session.
OR
I need a better way to temporary store a dynamic amount of information without submitting them to the database until the user clicks saves.
I hope some of this makes sense,
Thanks,
Aaron
UPDATE:
It turns out that my Page_load is fireing more than 1 time per post back. I have it narrowed down the the culprit but am not sure why it is causeing this. - When I take the below out of my WebUserControl the page load problem is fixed. FYI - the below code creates a pop-up that displays a list of checkboxes which allows a user to select more than one item - it it pretty involved with javascript.
<asp:ImageButton ID="btnFilterBUs" runat="server"
CssClass="MultiSelect" />
<ajax:ModalPopupExtender ID="btnFilterBUs_ModalPopupExtender"
runat="server"
OkControlID="btnOkBUs" PopupControlID="dialogBUs"
TargetControlID="btnFilterBUs">
</ajax:ModalPopupExtender>
<asp:Panel ID="dialogBUs" runat="server" CssClass="modPnl" style="display:none;">
<b>Select Business Use Types To Display:</b><br />
<br />
<asp:LinkButton ID="btnOkBUs" runat="server" style="float:right" >OK</asp:LinkButton>
<a href="javascript:clearCheckboxes('<%=lblSelectedBUs.ClientID %>', '<%=lblCheckedBUs.ClientID %>', BusinessUseTypeCBA);" style="float:left">Clear Selection</a>
<br />
<br />
<div class="modDiv">
<asp:LinqDataSource ID="BUsDataSource" runat="server"
ContextTypeName="US.QBE.BAR.Business.BARDataClassesDataContext"
TableName="AccountBusinessUseTypes"
Select="new (AccountBusinessUseTypeID, AccountBusinessUseTypeValue)" OrderBy="AccountBusinessUseTypeValue">
</asp:LinqDataSource>
<asp:CheckBoxList ID="cblBUs" runat="server"
DataSourceID="BUsDataSource" DataTextField="AccountBusinessUseTypeValue"
DataValueField="AccountBusinessUseTypeID"
OnPreRender="BUs_PreRender">
</asp:CheckBoxList>
</div>
<hr />
<br />
<b>Business Use Types:</b>
<br />
<br />
<asp:Label ID="lblCheckedBUs" runat="server" Text="None"></asp:Label>
<br />
</asp:Panel>
<asp:Label ID="lblSelectedBUs" runat="server"
CssClass="modLblSelected" Text="None">
</asp:Label>
<h5><asp:Label runat="server" Text="*" /></h5>