Set The Properties Of Server Controls As Early As In The Page_PreInit Handler?
Oct 8, 2010
An aspx page's Page_PreInit event happens before an component server control's (e.g. a TextBox) Init event. However it is possible to set a TextBox's Text property in Page_PreInit. I suppose this means the TextBox's Text is set before the TextBox is even initiated.
My users need to stay logged in for 1 day, so I used a persistent authentication cookie with an expiration of 1 day but it still times out after 20 minutes (which is the default timeout for the session, not the cookie).
I have a UserControl (basically a custom menu) that has some properties on it that I store in the view state. My pages may have multiple instances of this control, so to keep the values unique in the ViewState I concat my names with the control's UniqueId. However, when the properties are set the UniqueId does not exist yet, it returns the control's ID, in the case below, mnuFormNote. So then later when they are read it doesn't return the correct value because later the UniqueID is set so it attempts to read from a different ViewState location.
So, my question is am I doing something wrong or just missing something? If not, is there a way around this?
[Code]....
So when the page loads, and ShowEvents is set to False the property set actually does this: ViewState("mnuFormNoteShowEvents") = False. But later, when I attempt to Get the ShowEvents value it is doing this: ViewState("ctl00$ctl00$mstrContent$iepointMasterContent$dlForms$ctl00$dlStudentForms$ctl00$mnuFormNoteShowEvents"), which is nothing, so it returns the default of True. I need this value to be unique.
I have a class called EditMapUtilities. Here are some class properties that I want to persist:
public class EditMapUtlities { public static Boolean isInitialEditMapPageLoad { get { return SessionHandler.isInitialEditMapPageLoad; } set { SessionHandler.isInitialEditMapPageLoad = value; } } // REST OF CLASS NOT GERMAIN TO DISCUSSION AND OMITTED }
Here is my SessionHandler Class following the pattern from this post Static Session Class and Multiple Users: using System.Web.SessionState;
public static class SessionHandler { private static HttpSessionState currentSession { get { if (HttpContext.Current.Session == null) throw new Exception("Session is not available in the current context."); else return HttpContext.Current.Session; } } //A boolean type session variable private static string _isInitialEditMapPageLoad = "EditMapInitialPageLoad"; public static bool isInitialEditMapPageLoad { get { if (currentSession[_isInitialEditMapPageLoad] == null) return true; else return (Boolean)currentSession[_isInitialEditMapPageLoad]; } set { currentSession[_isInitialEditMapPageLoad] = value; } } }
I am still learning OOAD. I want to keep relevant properties with relevant classes. I also want to keep all Session stored variables in one place for ease of maintenance and to encapsulate the session keys and calls. I feel like my design is too coupled though. How can I make it more loosely coupled? Is my editMapUtilities class too tightly coupled to the SessionHandler class? How would you do it better?
I have a custom server control inheriting from CompositeControl. It consists of two RadioButtonlist controls that are rendered side by side in an html table. The number of ListItems in each RadioButtonList is not known until runtime. Depending on how many items each list contains, the RepeatColumns property of each list is set differently. To do this in the handler for the ItemDataBound event I need to get the count of ListItems in each RadioButtonList. How do I expose the Items.Count property of each internal RadioButtonList as a top-level property? I tried using a getter to return the count but this generates a compile-time error to the effect that the count cannot be assigned to--even though I have not created a setter.
Similarly, in the handler for the Submit event, I need to get the ClientID of each internal RadioButtonList to pass to a method that checks for data changes. How do I expose the ClientID of each component RadioButtonList as a top-level property?
I can of course index the Controls collection of the composite control to access the child control and read its properties--but that defeats the whole point of making a complex, independent custom server control.
am working working on an httpmodule to hide certain content on my website if certain criteria are not met. My handler setup is pretty simple. Here are the relevant parts to my question:
Public Interface IFeatureItem Property ID As Guid Sub FeatureItemPreRenderComplete(ByVal sender As Object, ByVal e As EventArgs) End Interface.....
This site has an mvc view for a dashboard and also contains webforms controls that could be an IFeatureItem. What I want to do is loop through the webforms controls in this view and do the same processing on them as I would on a normal page, but I can't figure out a way to do so and have had no luck googling. Is this possible within a module? Is PreRequestHandlerExecute the right event to set up my event handlers?
I am creating dynamic wizard steps in the Page_PreInit method , if i go ahead and refresh the form i get an error as follows :
Error : ActiveViewIndex is being set to '3'. It must be smaller than the current number of View controls '1'. For dynamically added views, make sure they are added before or in Page_PreInit event. Parameter name: value
this is my code to add the wizard control which exists in my Page_PreInit() method
I have created a control with two standard asp controls in (a label and a Textbox).I want to have access to the controls within but also be available from the designer so that the label properties can be prefixed with Label_ etc for example
[Code]....
How can I create a property from this reflection list?
I create a table in SQL server 2008 and add some colume
after sometime i need to change some properties of colume
but problem come when saveing the table. Error message shown:-
Saving changes are not permitted.the changes you have made required the table to be droped and re-created .you have either made changes to a table that can't be re-created or enabled the option prevent saving changes that required the table to be re-created.
In my web application, I have to load different Master pages depending on the user log-in information. When I say different, I mean not just the colors but a whole new look[including navigation options]. So I am using 2 Master pages [one of them is set as default] and depending on the user information the other page will be used.
I got it to work by storing the user information in a Session variable and applying the master page dynamically using the Page_PreInit event. But the issue is, if I hit the back button, sometimes [yeah, only sometimes !!!] the master page is reset to the default page. Initially I thought it is a Session timeout issue. But it isn't, as some of the session variables still have data. Can anyone explain whats actually happening?
I would like to ask you what is the best practice for developing composite user web control with multiple controls inside from the stand point of dealing with properieties. In my situation I would like to use header menu bar with logos, buttons, java baset visible/hidden menus itc as web control. I was successfull in implementing new control in my project.
But my question goes to issue of properties for ALL OF controls. I know how to hard code all required properties like: text, visible, enable for all controls. It's a lot of work. ( This is the very edge of my asp.net comprehension ) Is there a more elegant way provide an access to controls's properties without hard coding seperatelly?
If the answer to this question exists somewhere, I'm no good at searching for it. This is sort of a simple question, the response being two parts: (1) is it possible? (2) if so, how?
I've created a web user control for my site's footer. In my web.config I have it registered like this:
[Code]....
Then, within the pages on my site, I simply insert it like this:
[Code]....
But obviously, that didn't work. I get this error: The type or namespace name 'FooterControl' could not be found (are you missing a using directive or an assembly reference?)
So I'm really not sure what to do at this point. I can put all of my code in the ASPX file and make my life easier, but I would kind of prefer not to.
I would like to know why somethimes DefaultValue in properties window is displayed in bold text and somethimes in normal weight text? What i know is that the Value in Properties Window should display bold only if the Value is different than DefaultValue.
So i have a situation, where i need to set DefaultValue's and i'm successfully setting the boolean Value but failing in Integer value...
aspx:
[Code]....
Now the reason why i'm using Int32 in this example is that i hovered the mouse over the DefaultValue and it's said that "represents a 32-bit signed integer" but still no luck.
Why is my StepHour displayed bold and how to display this DefaultValue in regular weight text?
The above code compiles without any error. Also I can drag and drop this control from the Toolbox of my Project on my web form. However I am unable the change the value of my fromLabel control.It allows me to change the value in the properties window.But when I run the form it always shows me its default value which is "From". I want it to be flexible so that any one can change the value in the properties window.
I create custom HTTP handler for auto generating file and I want to tell IIS7 to serve current request like normal static file because I need to use IIS and web.config file to control compression setting and any other HTTP header of current requested file.I know. there is an internal class called StaticFileHandler in ASP.net. But I cannot access it. Or you have any other way to work like this.
I have a new VS2010 .NET 4.0 Web project and the Properties Folder has gone wierd on me. It has lost teh "Open" under the right click. There is no way to get a Settings file created now.
I am unable to get to the Settings grid and no Settings file is created. I tried the help and it has the normal trip of select Properties, Open (right click), Settings Tab, etc. etc.
How, or maybe where, is the session timeout handled when you set SQL Server as state handler in an ASP.NET application?
Is it the .NET framwork who after loading session objects from the DB does a judgement on whether or not the objects are expired, or is it a job on the SQL Server itself that takes care of this? The reason I suspect (or even concidered) the latter possibility, is that the script that created the ASPState mentioned something about a ASPState_Job_DeleteExpiredSessions-element.
If it is so that it is an SQL Server job that cleans up, how often does this job trigger and how does it align with the timeout parameter in web.config?
I need some jquery code in my application I have a button on the page and I want to handle it by jquery when the user click on it to show a confirmation dialog for example Are you sure? yes|no buttons but this is an asp.net button inside the updatepanel and in the other side I have some server side code to delete a record from database but my question is how I can handle both of them? server side and jquery inorder to when "yes" button clicked it runs server side and delete recorde from database and if the button is no it stop running ?
How can i add a click event to my entire table (not row or cell) that will trigger a server side method and not a JS method.I know i can add attribute which calls JS and then add post back as follows: