C# - Declare Global Variables In MVC?

Feb 25, 2011

How do you declare global variables in ASP.NET MVC?

View 6 Replies


Similar Messages:

Web Forms :: Declare Global Variables That Are Accessible On All Pages

Jan 9, 2014

it's possible to declear global variable in asp.net C#.

View 1 Replies

C# - How To Declare A Global Variable In MVC Page

Jun 4, 2010

I've began working with asp.net mvc very recently and I've ran into a problem.I've got an aspx page which renders a few ascx pages. What I'd like to do is declare a global var at the aspx page so it is visible to all its childs. I tried <% var i = 0; %> but it wasn't visible at the child pages. What could I do?

View 4 Replies

Web Forms :: How To Declare A Global Variable That Can Be Used Within A User

May 15, 2010

I would like know how to declare a global variable that can be used within a user after the user login and before the user logout across all the possible pages.

I need to develop a web application that will connect to 5 different servers depends on the selection of user on what server they wish to connect and after they select a server and login...I will need to keep track the server name in a variable last until the user logout (user may visit various pages but the server name MUST NOT be changed due to other user login into different server). So how can I do it so that other users may select different servers and will keep the server name for each different users.

Let says:-

User A selects Server A and login and User B selects Server B and login at the same time, so how the global variable can handle the needs for each user (User A & B) with different server select?

Is "Session" the only way to fulfill the above? I think of using Application State but it seems that the value stored will be shared by all users and not for a particular user.

View 1 Replies

How To Declare A GLOBAL Variable An Aspx Website

Aug 26, 2010

How to declare a global variable or a public sub in a web application that all aspx pages can have access to?

View 5 Replies

State Management :: Looking For A Way to Declare A Global Variable?

May 14, 2010

I'm looking for a way to declare a global variable (so all pages could see) but personal (so if one user puts some value in it, it won't matter to another user or change his value).Sessions and hidden fields won't do. I've tried working with declaring keys in Web.config but unfortunely, the keys values aren't personal, and all users share the same key value.Another way I was thinking was maybe classes, but perhaps there might be an easier solution?

View 19 Replies

DataSource Controls :: Declare Variables In A Gridview?

Jul 2, 2010

I´m having a SQL query statement in management studio that runs prefect. I can´t have it set in a gridview.In SQL management studio I´m declaring some variables. It seems like I´m not able to declare inside the query statement in a gridview. Do I have to do the declaring outside the gridview?Here is my code in management studio

[Code]....

View 3 Replies

DataSource Controls :: Declare Variables And Pass Values In Vb?

Mar 6, 2010

I need to declare a variable xyz, then, using a select statement, pass a variable into it so I can then insert it into a table.

Dim @xyz As
Integer
set @xyz = (select xyz
from systable)

1. I get a squiggly line below the @.

2. I get informed that set and let are no longer supported.

3. When I remove the @ I get the squiggly below select.

View 7 Replies

State Management :: Declare A Variable In Page Load{} As Global?

Jan 2, 2011

i want to declare a variable in page load{} as global so that i can monitor it so that it is not recreated each time

View 4 Replies

Web Forms :: Declare Global Variable In Master Page And Use It In Content Pages

Jun 16, 2015

how to declare global variable in master page and use it in all pages

View 1 Replies

C# - How To Use Global Variables In ObjectDataSource.SelectMethod

Sep 10, 2010

I'm using ListView + DataPager + ObjectDataSource mix.

In the implementation of my SelectMethod of an ObjectDataSource I'd like to access a global variable set in the PageLoad() event (the method will return just the proper number of items per page). Although the variable is initialized in PageLoad() it appears to be null in SelectMethod. How can I change that?

[Code]....

View 4 Replies

VS 2008 / How To Use Global Variables In A Web App As Like In Desktop

Sep 15, 2013

as we do in desktop app, can we use global variables in a web app. it must be client side.

i hv created a class to handle global variables, but the issue is with it. if other user login on another pc at d same time, the variable got re-initialized. i want they must be client/ user specific.

View 6 Replies

Web Forms :: Global Variables, Menus And Post Back?

Jan 8, 2010

with a problem im having or at least give me an idea about which direction i should be going in.I have an asax file - with the following void Session_Start(object sender, EventArgs e)in that I am storing a session which holds a boolean.This boolean holds a flag which when set to true tells the application to go to the database and retrieve data, if its set to false, it checks the information in memory.I am using master pages and inside my master page i have and ascx files - which holds my navigation items(I build the navigation menu based on certain criteria)on a content page (a page that uses the master page) I perform a function when a button is clicked and I set the session flag to truethe problem is that the flag is not being checked until i refresh the page twice and therefore the menu is not updating until the user clicks to another page.my suspicion is that it is because of the page life cycle (the event handlers are done AFTER page load) - is there anyway around this?Is there any web page links you have got that I cant google? (yes i have googled but to little luck - maybe im using the wrong search term).on an additional note im trying to avoid like the plague - storing anything in the viewstate

View 9 Replies

Accessing Static Variables From Global.asax In Aspx.cs Pages?

Feb 13, 2011

i declared a static variable in global.asax file like below

<%@ Application Language="C#" %>
<script runat="server">
static string Sv;
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
}

i want to access this variable in aspx page. how can i access this variable.

View 2 Replies

Javascript - Access Global Variables That Are Set Inside An Event Listener?

Dec 18, 2010

I am working with Google maps api V3. I need to get the values of the getSouthWest & getNorthEast bounds of my map. To do this the 'bounds_changed' event needs to be fired in order to get the new values. This is all good, however, I need to access these values from outside the event and passed to a server side function (more specifically, I don't want to call my server side function every time the map bounds are changed).

My code is:

//Global
var sw, nw, Searchbounds;
function myFunc(){
google.maps.event.addListener(map, 'bounds_changed', function() {
Searchbounds = map.getBounds();
sw = Searchbounds.getSouthWest();
ne = Searchbounds.getNorthEast();
});
CallServerSideWebService(sw.lat(), ne.lng(), ne.lat(), ne.lng());
}

When executing this code I get the error message sw is undefined.

View 2 Replies

State Management :: Using Global.asax To Set Session Variables Pulled From SQLServer?

Sep 3, 2010

I have a custom class that pulls user information from a SQL Server table. Now that I'm expanding the site from a single page to others. I want to shift the code to the Session_Start event so that the information is always loaded when the site is accessed. How do I call my custom code from global.asax since its script and not a class.

View 5 Replies

Web Forms :: With Javascript, Does A Response.redirect Clear Out All Global Variables And Values Declared?

Feb 7, 2011

For some reason it seems as though variables that I declare in javascript sometimes persist themselves across applications even when I do a response.redirect. I thought that a response.redirect would clear them out.

View 1 Replies

C# - Dictionary Lookup Efficiency & Request Scoped Global Variable Accessible By Global.asax And Pages/etc?

Feb 8, 2011

I know there is a couple answered questions on here regarding "request scoped" globals, but I want to nit-pick on something specifically and maybe squeeze some extra enlightenment out of one or two of you.I have an ASP.NET C# Website and a static Dictionary of objects (loaded from DB once on Application start). Each page request will need to do a lookup in the Dictionary (based on a key derived from the request url/etc) and get the appropriate object.The issue is I'm trying to maximize efficiency by reducing the lookups to the Dictionary per Request. Doing just a single lookup within a Page itself is easy enough and I can pass the object to sub controls, etc too.. but global.asax is separate from the Page and it also needs to use the object (in Application_BeginRequest and Session_Start).

So is doing a Dictionary lookup once in Application_BeginRequest, once (when necessary) in Session_Start and once in the Page negligible speed wise, even if there are many requests coming in every second?I would like it if I could just have a Request scoped global variable that I can easily call upon.. the only one I see available though is HttpContext.Current.Items and that is a Dictionary itself.Am I beingridiculously nit-picky with my concern over efficiency? or will these milliseconds (nanoseconds?) get me in the long run when more and more requests are being made?

PS. I currently only have around 100 objects in the Dictionary although this may increase in the future.

View 2 Replies

Collect 2 Variables From One Hyperlink, And Use Those Variables In The Page_load To Set As Session?

Aug 8, 2010

i am trying to collect 2 variables from one hyperlink, and use those variables in the page_load to set as session. but i don't know how to collect those 2 variables

such :

<a href="javascript:;" onclick="wsChangeColor('mainData', '#FF0000','#FFE4E1');return false;" title="Change color" id="red">1</a>

i would like to collect '#FF0000','#FFE4E1' or direct set '#FF0000','#FFE4E1' to string then send to pageload, how can i do this by only clicking on it ?

View 1 Replies

Web Forms :: Storing Javascript Variables Into C# Variables

Jan 2, 2010

I have this code in javascript: var x = e.mapX; It gets the X-coordinate of a map. What I want to do is that I want to store this into a c# variable. I have a class named Test with an integer property X. I want to store var x into X. In the codebehind, I have this on the Page_Load: Test test = new Test(); Then I am trying this on the javascript code: var x = e.mapX;

View 16 Replies

Working With Static Variables / Store The User Specific Information In Static Variables?

Mar 5, 2011

whats the exact use of static variables in overall programming in .net and for asp.net...

Recently i went for the interview where interviewer asked me 2 question which i was not sure for the same..

whats the use of session object, i said sessions are the server side object, they are used when you want to store user specific data at server side, then he asked what if i want to use static variables for the same, i was mum, can anyone tell me how asp.net will behave if i store the user specific information in static variables.If i use cookies which are the best option to store the data at client side (not sensitive one), but what if user has disabled cookies on his machine, will my application would crash.

View 3 Replies

How To Declare Variable For Whole Of Project

Jan 11, 2010

i want to declare variable for whole of my project , i mean for solution, where and how should i do it?

View 16 Replies

Declare A CSS Stylesheet One Time Only?

May 9, 2010

if i have a single CSS stylesheet for a website and only want to declare it once, that is, not use the following code on every aspx page..

<link href="stylesheets/general.css" rel="stylesheet" type="text/css" />

Am i forced to use a .master page? or is there another way to do this..

View 3 Replies

C# - Declare A String Rather Than Address?

Dec 6, 2010

alt="" src="ftp://192.168.1.17/Chrysanthemum.jpg"
style="height: 299px; width: 317px"

how do I declare a string rather than address for ftp? i would like to say

alt="" src="imagePath"
style="height: 299px; width: 317px"

how would I declare that in my actual c# aspx.cs code? And in this code above?

View 2 Replies

SQL Server :: How To Declare Primary Key

Aug 1, 2010

ALTER PROCEDURE dbo.Select_Customer
(
@UserId varchar(100),

[code]...

View 15 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved