C# - User Control Losing State
Jun 27, 2010
I have a user control that I am explicitly calling from an aspx page. In page_load of the aspx page I have the following: myControl = (DynamicTable)Page.LoadControl("../inc/DynamicTable.ascx");
Then in my code where I want it to execute the control, I have this: pnlESDDEnrolled.Controls.Add(myControl);
where pnlESDDEnrolled is the panel I am loading it into for display. So, I execute the aspx page, it links off to the user control, populates the control, returns back to the aspx page and the page displays with the user control in the middle of it. All is well.
The problem comes in when updates are made on the user control. Keep in mind, that other data is updated on the page as well, and the update button resides on the page, not the control. Anyway, when the update button is pushed, the button_click event is fired on the page, but the updates that I made on the user control are lost. Since the page loaded the user control and then the usercontrol executed the page unload method, the page has no knowledge of the user control anymore. Thus, when the update button on the page is pushed, I guess I am not really sure what happens with the updated data on the user control. All I know is that it is lost.
View 2 Replies
Similar Messages:
Feb 2, 2011
I am trying to set a session variable in the global.asax file and keep running into the problem that the Session is null.
I am running my application in VS2008 and using asp.net 3.51.
Here is my code:
1. In my web.config file I have enabled the session state and added the following line;
<sessionState
cookieless="false"
mode="InProc"
timeout="60"
></sessionState>
2. In the Session_Start procedure in the Global.asax file I set the session variable to a default value.
[Code]....
My problem seems to be that when the Application_Error procedure is executed the session state is lost.
Does anyone know why the session state isn't available in the Global.asax file.
View 9 Replies
Dec 28, 2010
how to create unlimited user control without losing the data... My problem is on postback.. i searched a lot but m not get solution.. my question is how to recreate unlimited controls(textbox,dropdown) and how to maintain the data in the controls.. Now am able to create dynamic usercontrol (unlimited) when Button click event using for loop but not able to maintain the data during postback.
View 1 Replies
May 13, 2010
I have two radio button list:
*1* report views -- 4 options -- NOT in updatepanel
*2* pagination views -- 2 options -- IS in updatepanel
The situation goes as follows: Refresh WORKS in default setting but when I select *2* radio button options and refresh the page renders the state that the (1) was entered in.
Example: () are the radio buttons
Report Viewing: () (x) () () Pagination View: (x) () REFRESH works!
Report Viewing: () (x) () () Pagination View: () (x) REFRESH fails to display Report Viewing: () (x) () () Pagination View: (x) ()
Report Viewing: () (x) () () Pagination View: (x) () REFRESH works!
OR: () are the radio buttons
Report Viewing: () () (x) () Pagination View: () (x) REFRESH works
Report Viewing: () () (x) () Pagination View: (x) () REFRESH fails to display Report Viewing: () (x) () () Pagination View: () (x)
Report Viewing: () () (x) () Pagination View: () (x) REFRESH works
I am using the session variable to hold the Pagination Viewing option but during page states, I've noticed that when a 2nd option is selected of *2* radio buttons (doesn't matter of 1st or 2nd option was initially selected) that during debugging mode the step over corrects the issue but not the right table viewing. Upon entering Page_Init selection selection index of radio button list returns to 1st option.
View 4 Replies
Jun 22, 2010
i read the tutorial on msdn,what i want is to basically make astructure like of gridview, but not gridview.i want that when a post back occurs by any control the table does not lose its data, it preserves its state.as a result i am not able to add rows to the table in an increment fashion, everything gets destroyed on postback.
[CODE]...
View 1 Replies
Sep 1, 2010
We have a web site that implements a custom SiteMapProvider using a User Control added in the master page. I need to be able to limit the sitemap nodes added depending on the logged in user, that is, certain users should not see certain sitemap nodes. Currently, the login processing code determines if users are in the certain category or role and then sets a value in session state, for example, Session["UserInRoleXXX"] = "Yes"; I tried changing the code in the user control to check the session state, but I got the following error: NullReferenceException ... Object reference not set to an instance of an object." Can session state be accessed in a user control?
View 6 Replies
Mar 27, 2010
I am in beginner level on developing web pages. I was coding on desktop applications and as you know it is easy to say that web applications are extremely different than desktop applications.
I wonder why data are lost between postbacks.???? And what is the best way not to lose the data belonging to a specific control (especially gridview). Session or viewstate or anything else?
View 10 Replies
Dec 13, 2010
Never had this happen before. I just upgraded my site from 3.5 to 4.0. Here's the scenario:
1.) I have a literal on a web form, in an UpdatePanel.
2.) On PostBack, the Literal's "Text" property loses it's value. The ViewState is enabled throughout the page. Further, I changed the Literal to a label and it also has this problem. The TextBox's appear to keep their values.
3.) If I remove all of the Ajax controls (which currently is just the UpdatePanel and the ScriptManager) then the Literal control keeps it's value through PostBacks.
4.) There is no client side JavaScript where I'm manually changing the values of these controls. They are only editted in the server side events.
I have read that setting the AutomaticDataBind property in the web.config could remedy this but I can't find any documentation on it and I don't know where to put it in the web.config to even try it.
View 7 Replies
Dec 28, 2010
I'm fairly new to ASP.net development as may have been noticed by some of my other posts and so here goes another one.I have a web page in which I allow users to enter data that will be used to populate a database and then graph data based on the information that was saved in the database. I have 10 sets of criteria that the user can enter and as they enter values for each individual set, I make sure all the parameters are filled in and set a variable called blnParm1, blnParm2, blnParm3, etc. Anyway, as each DropDownList box fires off an event the values of my blnParm variables is reset because each time the event is fired the page is PostBack therefore my variables are redeclared. I know the page is being PostBack because each of the DropDownList boxes have AutoPostBack set to true. I had to do this so that I could get the OnSelectedIndexChanged event to fire for each of the DropDownList boxes. So, how do I preserve my variables through this PostBack or how do I get the events to trigger without calling AutoPostBack?
Some more info, my variables are declared globally in my aspx.cs file as private bool. The code is working like it should as far as populating drop downs dynamically based on other data input by the user, the controls all have their values preserved as the page is PostBack.
View 2 Replies
May 10, 2010
I have a asp.net application where I am saving off into session the user privilege information. From a grid I am bring up a new window by using the window.open. It seems that it is whiping out the values in session. A temporary bandaid I have placed on it is to recall the database if the value is nothing to reset the user object. I have found all over the internet that this is an issue with the window.open in IE 7 and IE 8. Has anyone else run into this and able to actually fix it?
View 4 Replies
Mar 14, 2011
There are a couple of user's experiences session variable loss after they've clicked a confirm button and their information is email via a relay hosting server. Below, I commented exactly where the session variables get lost.
What could be causing the session variable loss? So far, this only happens to a few users.
Part of the email that gets sent out:
[Code]....
Web config file:
[Code]....
View 4 Replies
Oct 25, 2010
This is weird. In my newly developed chat application, when I invoke Response.Redirect, I am losing my session data. What is particualrly odd is that this sometimes seems to occur after a slight delay, so I reach the page, and then the session info gets lost momentarily thereafter. Mostly though it seems to get lost immediately. I have of course googled this issue, but yet to find anything that speaks to my problem. SessionState is in InProc mode. Session state has been working fine for me until this unexpected problem, so everything is configured right. So far the only workaround I can think of is to use a link instead of a button, and use javascript to call a server-side function on onclick to do the work I need to do before the link gets invoked. Messy, and I'd rather not go that way unless there's no alternative.
Just to preempt one red herring, I do use Response.Redirect(<address>, false).
The problem occurs both on the testing and production servers. I'm running ASP.NET 3.5 on IIS7.
View 1 Replies
Jan 8, 2010
How do you work-around the fact that sessions are dropped every time you deploy certain code files to an ASP.NET website? Sometimes we need to deploy a crucial fix in the middle of the day but don't want to boot off all our users for it.
View 3 Replies
Aug 11, 2010
I am baffled, I am using a treeview to set the source of an iframe. The web page is being displayed correctly, but User.IsInRole("roleName"), in the code behind, always returns false. The strange thing is User.Identity.Name returns the correct user name. I have tried setting the target of the tree view nodes to "_blank" and to "_self" and still no luck. So, it doesn't appear that the problem is related to the iframe.Before the treeview was added, javascript was used to set the source for the iframe and User.IsInRole returned the correct values.
View 4 Replies
Nov 25, 2010
We're currently deploying code to live pretty reguarly at the moment, but the down side is destroying user session data.
Is there a way of being able to recycle IIS without loosing session data, or is persisiting session state in SQL server or alike the only way?
View 2 Replies
Aug 6, 2010
I have a aspx page and there is a web user control that must load dynamically with the data related to the aspx page....
ok so I want to use a querystring and pass it to the web user control.....how do I do this?
then also how do I pass a querystring from a web user control back to a aspx page?
This is a question I always had...and therefore never actually started to use the web user control
View 5 Replies
Mar 31, 2011
I have created a user control with a property named CurrentPage. When a link button is clicked it runs PostbackToPage() and passes a command argument in which then sets the CurrentPage property with this new value. On the page which uses the user control I am trying to display the updated CurrentPage property after a postback. When I click the link button to cause the postback the CurrentPage is the default value. However when I click it again it works as expected. So it seems to only work after 2 postbacks. How can I get this to work after the first postback?
User control code behind:
[Code]....
User control design:
[Code]....
Page which uses user control:
[Code]....
View 5 Replies
Sep 9, 2010
I have a user control which has html elements like <input type="button".... and i want to set its display property on preRender state.Would you please explain, what kind things i have to handle this user control? So, in this functionprotected override void OnPreRender(EventArgs e) { }
I have only EventArgs e and it doesn't have proper method or properties to bring me the html of user control.
View 1 Replies
Mar 5, 2010
1) I found that my viewstate was not being persisted across postbacks for web user controls. I ensured that the Enable Viewstate property was set to true (of the page)
2) The Viewstate isnt being persisted on the 1st postback.
3) However, it is being persisted from the 2nd postback onwards.
I stepped through the code to ensure that the Viewstate had the 2 keys that I was adding on page load. However, on the 1st postback, the viewstate is empty. Everything is ok from the 2nd postback onwards.
[Code]....
View 3 Replies
Feb 23, 2011
Been scratching my head on this one today quite a bit. Time to ask the guru's.Implementing your basic Forms Auth for a 2.0 web app in conjunction with SQL Membership Provider and Role Provider. Web.Config from virtual directory root
[Code]....
All other subdirectories do not contain web.config files but rather wanted them to just work off inheritence from the root web.config. Upon publishing of this setup - I am having one hell of a time maintaining the user 'authenticated' state. (Not sure if that's the best explanation of what is going on.. but)
View 4 Replies
Feb 10, 2011
i have a usercontrol called navigationmenu whose data is static but varies with loged in1.empID 2.empType 3 Country my question is how can i cache the data of usercontrol based upon combination of these 3 parameters
View 9 Replies
Aug 26, 2010
i have 2 questions about output cache:1.is it just me , or does it seems that it is used only after the second time that the user reaches the webpage? if so, why, and how can i tweak it to my needs? my guess is that it wouldn't be logical to cache every time a user reach a webpage, but only when it happens enough times.2.i know that i can use "varybyparam" for using the output cache when the parameter doesn't change , but it seems that it would use the output cache even if there is no parameter , or if the specified paramter is not there. is there a way to overcome this?3.an old question that somehow marked as "answered" , yet i didn't solve : suppose i created a user control and i gave it values through the CTOR via the aspx file . is it possible to show the values from within the split/design mode? remember that i've talking about ASP.NET and not simply C# winforms . i write this because this question was on :[URL]and the answer that i got was for C# and winforms . i've tried to do the same for ASP.NET , but i've failed.
View 6 Replies
Feb 23, 2010
I am building a composite server control that currently only has a TextBox and a DropDownList. Here is the code in all its foetal glory:
[Code]....
The control appears to work correctly across postbacks, that is until declarative values are set, e.g.:
<squee:Address runat="server" ID="a" Street="123 Fake St" State="VIC" />
After this, the text box continues to work correctly, but the _state member does not pick up the posted back values and instead just sticks to the declared value. I've checked the raw posted values in the Request object, and the new value for the list's UniqueID is there, but _state doesn't pick it up.
View 1 Replies
Mar 29, 2010
I'm trying to use an Ajax Accordion Control with IE6.
I'm losing the background-color specified in the CSS.
I've tried this fix I found on the forums here, but I'm still not recieving the background-color.
The Accordion:
<cc1:Accordion ID="Accordion2" runat="server"
FadeTransitions="True"
SelectedIndex="0"
TransitionDuration="300"
HeaderCssClass="accordionHeader"
ContentCssClass="accordionContent" CssClass="normalRow">.........
View 7 Replies
Nov 24, 2010
I've created loads of user controls, but this is my first time dealing with extending a server control. The problem I'm getting is that the base control's data is not being persisted across postbacks in a Master/Content page.I'm actually trying to get this working using a Telerik control (for my sins), but the same issue happens with a standard Web TextBox control. Code:
[Code]....
Now, I've copied the way I handle the control state as I do it with user controls (ControlState), and it isn't working. Can someone point me in the right direction please? All the examples I find refer to creating user controls, not extending existing controls. Specifically why nothing is being persisted on post back.
View 7 Replies