I have a question about C Sharp ASP.NET:Is there a difference (in code speed, resources) between:public static variable declared in public static class MyGlobals in a 'Code File' template;and the variable declared in a normal 'Class File' template;I use this variable in 2 different Class Files and also in _Default Page codebehind cs file.In fact in my case I need about 20 global variables of type List<string>.
I have a problem to pass along public variables from C# code to the HTML code. I assign the variables in the Page_Load event and then pass along them to the Panel and Image control in the HTML code. Though I get this compileerror for the Width: "Cannot create an object of type "System.Web.UI.EbControls.Unit" from its string representation '<%setWidthImage%>' for the 'Width' property."
How do i call a variable in different subs on the page? I know I need to create a Private_Sub....? But I don't know the how to complete it. For example, I have the following code in a Button Click event. But I also need xamount in a different Button Click for the same page. Like I said, I believe I need something like a Private_Sub or Protecetd_Sub (not sure which one and why) with a made up name to reference it....like Private_Sub subXAmount, but I don't know how to complete it and then reference it.
I have a web application which uses a session variable to store the logged in userid. If no user is logged in, of course this variable will be empty and the contents displayed on my website are meant for guests. If there is a user logged in, the user specific controls/access/links will then be a displayed.
I am now having issues with my hosting where on shared application pool, the worker recycle is triggered every 90 minutes, this will clear sessions causing all my users to be logged out. I opted for a dedicated application pool, which got worse because I am only allocated 50MB memory limit and if this is reached, the worker recycle is triggered and I lose my sessions again. I have tried as much as possible optimization techniques, e.g. dispose where possible, close connections, disable viewstate for static controls etc but my memory per instance keeps building up from page to page without any signs of improvement. I don't use loops nor store huge objects like bitmaps etc but my sessions are now gone even faster than 90 minutes in shared application pool before.
I have considered using SQL Session State but there isn't a simple guide on using this with MySQL. I am getting desperate and considering using a public variable, a string as a replacement to store logged in user id instead of in a session variable. I am pretty sure this will solve my issue with sessions being recycled but are there any negative consequences of doing this? One problem I can think of is if the user closes the browser, the system will never know that the user is now logged out and this public variable should be nothing. In this scenario, will the GC eventually clear this abandoned public variable.
I have a publice variable to be used in the same webpage. when the user click on button 1, it does some process and assign a value to my public variable. After that, the user can click on button 2 which needs the public variable value to function. However I see the value of the public variable is 0 when I click on button 2.
I have a variable in an aspx file I need to use/recover it's value into an ascx web control that's in this aspx file. It's possible to do it? The aspx dynamically loads web controls depending the scenario, so this web control not allways is loaded.
I have declared a variable as public (Visual Basic 2008). As a result I can call its value in all subroutines. However I cannot change its value in any of the subroutines?! How to do that? The variable I'm having trouble with (see code below) is called 'antwoordbestand' and I want to change its value in subroutine startKnop_Click.
Can someone explain to me the rules around what can and cannot be evaluated/inserted into markup using the <%# %> and <%= %> tags in asp.net?When I first discovered I could inject code-behind variables into mark-up using <%= I thought 'great'. Then I discovered that if such tags are present you can then not add to the controls collection of the page (that's a whole different question!). But <%# tags are ok.
Is there a way I can inject a code-behind variable or function evaluation into the page using <%# ?
Im a fan of the EF code first and with its last preview of the CTP5 I wonder if it would be safe for me to use this for a smaller site for customer? I would love to get your opinions on this? And any good sources for tutorials and information would be sweet. I'm currently reading the post on scottgu's blog about it.