Vb.net - Declare A Public Variable And A Public Sub In An Aspx Web Page?
Aug 26, 2010How do declare a public variable .aspx web page that can be used in all the pages within my web application? And/or create a Public Sub?
View 3 RepliesHow do declare a public variable .aspx web page that can be used in all the pages within my web application? And/or create a Public Sub?
View 3 RepliesI am trying to declare a public property and access it from another page. I can't seem to be able to declare it. I'be tried putting in the code behind but it gives me errors.
View 2 RepliesI 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>.
View 9 RepliesI 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.
View 2 RepliesI'd like to know how to declare a variable in my code behind page that I can use in all the subs of my code behind.
I tried in after the Partial Class declaration to declare a "Public String" :
[Code]....
and to use it in my subs but when I use it from a sub to another I loose the value affected in another sub.
Is there a way to use a Public variable from a sub to another (I'm actually using a session variable in order to do it and I'm not sure it is the best way)
I can access a module from code behind but not from the aspx page in inline VB code <% ... %>.
I know its got to be something simple but I can't seem to find the answer anywhere.
How can I call a public property declared on a ASPX page from a different ASPX Page? Is that possible? It is a website project. How can I get/call this property from a different aspx page? I have attempted this from the other page, but it is not recognizing the partial class: private Test_Default _test; It does not recognize the "Test_Default"
I.E.
[code]....
I have a problem with calling a method on a aspx page from a usercontrol.
The case is: I have 1 main page with 5 usercontrols, when something goes wrong in the code I want to display the error message in a Modalpopup Extender. I can create for each usercontrol a different modalpopup extender but isn't much easier when I make 1 popup in the aspx page. But the problem is: How should I call a method in the aspx page that open the popup?
I have search several hours on the internet but can't find anything useful.
How to make a reference to public const string from aspx page with c#
In VB its <% = MY_DATA%>
I have a public void procedure, which is on my master page, and I need to be able to call this from aspx page as it is common to a number of pages that will use my master page. How do I do this?
View 12 RepliesI 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.
My UI layer calls my business layer which populates a DTO. I need to display properties from the DTO on my ASPX page. Should I create public variables on the code behind page for each of the DTO properties and reference like <%=PublicPropertyName%> OR is it ok to set the DTO instance to public and reference the properties directly like <%=dtoInstance.propertyName%>
Additionally, would it be better if I just created Literal and Label controls for every item on the ASPX page and just populate them from the code behind only?
[Code]....
The variable is assigned a value in another class like this:
[Code]....
public static string SEARCH_STRING = "searchkey";
string key=Request.QueryString.Get(SEARCH_STRING);
How to change the above code to make SEARCH_STRING be accessed using a Property(get; set;) instead of a public variable
[Code]....
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 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."
[Code]....
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.
[Code]....
i have 2 aspx files . I need to access a public function in b.aspx from a.aspx. How can i do that in asp.net using C#
My function from a.aspx is the following:
<script language="C#" runat="server">
public String user()
{
return l1.Text;
}
</script>
Can I put public static int[] MyArrayCounter declared in separate class Main.cs into webpage Default.aspx between code tags <%= %>?
More info of what i do:
I have declaration in Main.cs:
[Code]....
In class Checking.cs i fill MyArrayCounter with 29 values. After code execution ends, i'd like my Default.aspx page to bind to that MyArrayCounter values like:
Label1.Text = MyArrayCounter[0]
Label2.Text = MyArrayCounter[1]
etc.
I have this public property in the codefile of an aspx page:
[Code]....
Then in that aspx page I have a usercontrol (.ascx), how can I access the above public property form its codebehind?
i have written following code to access public variable of asp.net onclick event on button but its not giving me desired output.. please check it:
<asp:Button runat="server" CssClass="txtdisplay" ID="Button1"
Text="Browse all jobs in area"
OnClientClick="return navigateURL('index.aspx?c=<%=cityid %>')" />
Is there a way to call a public function from a class?
[code]....
How to declare a global variable or a public sub in a web application that all aspx pages can have access to?
View 5 RepliesI have an ASCX.vb page that lets the user choose someone from a table. Once they do select someone, the page reloads with that persons information into another table below that one where they can submit an order for that person or remove that person.
Problem being is that i wanted to store the users ID that are selected but it seems that everytime the page reloads to show an update, it dim's my array again back to default.This is my code once they choose a user:
Code:
Namespace prog.Controls
Partial Public Class progReportGrid
etc....
[code]...
So when the page loads and i choose a user, it tells me that strID = nothing and i know it at least should have 00007700000 in it?
in asp.net can i make public objects on my page, for example
public Customer cust1 = new customer();
and use this object on my entire code?
what are the drawbacks of creating public objects??
a single object will be created for all users??? or each user will have a different object?