Page Scope Variables In .NET?

Dec 7, 2010

I need to access some variables in a page in web application. The scope of variables is just in that specific page.
which one is the solution ? Session or ViewState ? or any better solution ?

Private Property UserId() As Integer
Get
If Not ViewState("UserId") Is Nothing Then[code]....

And also Is ViewState custom per user?

View 1 Replies


Similar Messages:

Is Context.Items User Scope Or Application Scope

Apr 6, 2010

I want to use Context.Items to store some info of a User Control like:

Context.Items["Data"] = 5;

I want to know, Is Context.Items is for each request or it is global for the application?

View 1 Replies

Forms Data Controls :: List Of Anonymous Types At Page Scope?

Nov 21, 2010

I have a listview in which I have a dropdownlist that will be repeated about 8 times. In the itemdatabound event of this listview, I fill the dropdownlist of that particular row with data. I obtain this data by using a linq query. It gets me an anonymous type in return:

[Code]....

The problem with this code is that I fire a query to the database everytime the itemdataboundevent is called. What I want to do is to fire the query only once, and have it available at page scope so I can reference it in the itemdatabound event. How can I get it like that?

View 1 Replies

Web Forms :: Passing Variables To Child Page From Master Page

Aug 17, 2010

I need to access a variable that is declared in a master page to a child page. I'm using asp.net 2.0 (vb). I'm sure this should be easy and is down to my inexperience with asp.net! A rough guide to my code is below;

MASTER PAGE
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<script runat="server">
Public UserNumber As Integer = 3
End Sub
</script>
CHILD PAGE
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>

View 2 Replies

How To Access Master Page Variables From .aspx Page

Jan 8, 2010

how do access master page variables from .aspx page

View 1 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

SQL Server :: Any Alternatives Of Using Transaction Scope

Jan 24, 2011

I have a multiple database operation, Have three tables (MSsql) and need to delete one row in each table in one operation, one after another. (Three functions, three rows of code). Everything is working as it should be, recently I was advised to use a transaction scope, which should guarantee the safety of deletion from all 3 tables together.
Here is my new code:
[Code]....

Locally all worked just fine, the transaction scope worked well, but when I have uploaded my application to my hosting server, I got an error of: The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025).I talked with the host support, they tried to do something, then I got this error: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

After a 2 days, They have contacted me, they said it is not possible to disable some restriction, that will allow an access to this operation, because I'm using shared hosting, and I need to upgrade my plan to VPS. VPS is a very expensive for me, and I can't afford it, What I'm looking is a some similar way of doing the same operation as transaction scope do, that may work at my hosting, At least I would like to try something else. Is there any additional way for the transaction scope?

View 1 Replies

MVC :: Strategies For Managing Security Scope?

May 17, 2010

In this case I have a system where a user logs in, they get a dashboard and they can see all their related projects. The user can click on the project and open it. (ie /View/79) The problem the user can also just type /View/68 which they are not supposed to be able to view.

Obviously I am aware of how to filter my data, but this application has many many lists of data and it all needs to be scoped to data that user has been allowed to see. I can insert a plethora of joins and wheres in all my queries but.. it's a lot of work and a bit convoluted.So I was wondering what strategies other had used for filtering data based on the user scope.One approach I was thinking of was to extend my user-role-permission model so "permissions" could be assigned to various entitites (like projects). This way, rather than doing a series of joins etc to see confirm a user has been assigned to a project, my join is just onto the EntityPermission table to confirm the user has PermissionX (like: CanView) on that entity. I could either maintain a seperate M2M table for each entity i need to restrict or something a bit more general (but without referential integrity).

View 3 Replies

Retrieve Web User's Identity Outside Of Request Scope?

Feb 14, 2011

I have an ASP.NET app that logs Audit reports using nHibernate's IPreUpdateListener. In order to set the current user in the Listener events, I was using System.Security.Principal.WindowsIdentity.GetCurrent(). This works fine when debugging on my machine, but when I move it to the staging server, I'm getting the ASP.NET process credentials, not the requesting user.

In the ASP.NET page, I can use Request.LogonUserIdentity (which works fine since I'm using integrated authentication), but how do I reference this user directly without having to pass it directly to my event? I don't want to have to pass this info through the pipeline because it really doesn't belong in the intermediate events/calls.

View 1 Replies

C# - Finding Session Alternative In Global Scope?

Feb 24, 2011

Quick question: Is there a "per-user" data storage object (similar to Session) that I can store data in the global scope (similar to HttpRuntime.Cache)? Almost as if Session and HttpRuntime.Cache had a baby.

Full Background: I have a ASP.NET website that was originally written for a single thread. Now I changed it so that certain actions will spawn a background thread and the browser polls a service to get status updates.

The problem I am having with this is that certain pieces of data are stored into the HttpContext.Session[] object (membership authentication token, for example). These pieces of data need to be unique to each user and accessible to the background thread. Session is not available to the background thread.

I am aware of HttpRuntime.Cache but that would require micromanagement to segment out the users and to expire it at the same time the session is expired. Session, on the other hand, automatically expires this things at the right times that I want it too and is already used by things like the SqlMembershipProvider.

My question is, is there something that behaves similar to the Session but exists in the global scope?

View 3 Replies

C# - Handling User Security Scope With NHibernate Or Other ORM?

Jun 5, 2010

How should one handle the situation where you may need to filter by a group of users.

Here is the scenario.

I have an administrator role in my company. I should be able to see all the data belonging to me plus all the other users who I have control over.

A plain old user however should only be able to access their own data.

If you are writing regular sql statements then you can have a security table with every user and who they have access too but i'm not sure how to handle this situation in the OO and ORM world.

Any one dealt with this scenario in a web application using an ORM?

View 1 Replies

C# - How To Create A Variable With Project-wide Scope

Feb 28, 2011

I want to declare a variable in such a way that I can access that particular variable and its value in all the asp pages in the project. Can anyone tell me how to declare a variable in C# such that it has project-wide scope?

View 8 Replies

Send SMTP From With A C# TransactionManager Transaction Scope?

Oct 25, 2010

Trying to troubleshoot a questionable plugin a client is experiencing issues with in production, and one possible issue I see is the fact that they're sending SMTP synchronously from within our heavily-transacted C# web application. In the past I believe I've read or been told that sending SMTP synchronously from within a transaction is a precarious bet, but I can't seem to find anything to back it up that I can present to the client's dev team.

View 1 Replies

C# - Events Through Application Scope To Multiple Clients?

Feb 15, 2011

First of all, I am creating a something like a client/server solution using a standard ASP.NET website - I do know this method is not adviced, and most people would love to scream "COMET!" or "HTML5 Sockets!" - but please don't ;-) !

What I am doing...

I am creating an MMORPG on a website.

I have several clients whom need to be in contact at the same time. This is done by a global object in the Application scope.

My problem

I need to invoke an event to several clients. For instance, when an attack has been performed, I need to update some graphics. The attack logic is resolved in the global object, but each of the clients has to respond to this.

Right now I do the following:

fightTrace.Reciever.InvokeMoveEnded(this);
fightTrace.FiredBy.InvokeMoveEnded(this);

(This is a kind of observer pattern)

What now happends is a race condition. The one who loads the page_load event will get both of these events, and the one who is not running them, will experience no changes in the UI.

So what is it I really want?

What I really need is some genuine and nice way to create an observer pattern through the application state. I need to send an event out to every "listener" which is in this case is a client, and then do some update.

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

Pass Variables From One Page To Another

Jan 17, 2011

I want pass the current page variables to next page and further also.

How to do this?

I was able to handle this to next page by previous page variable property but not further.

View 3 Replies

Get An Error When Try To Load A Report Current Data Set Scope?

Sep 30, 2010

I always got the error below when i load my report.i cannot get it since i have already added the field on my data set.{"The Value expression for the textbox ‘textbox22’ refers to the field ‘isTransfer’. Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope."}

View 7 Replies

C# - Initiate User Scope Class At Session Start?

Jun 16, 2010

I want to initiate a class for each user at the start of the user's session so that a single class can be used throughout the user's session. I checked out this post but I'm not sure where I should be placing this Sessionhandler class. Inside global.asax? How do I go about accomplishing this?

View 2 Replies

C# - Difference Between Transaction Scope And Manually Defined Transactions ?

Jul 22, 2010

just reading about using transaction scrope, previously I am used to making transactions inside a single DB class like

try
{
con.Open();
tran = con.BeginTransaction();[code]...

Which one is the recommended coding practice and why ? Is using a Transaction Scope safe ? Is it the latest way to do things ? I am confused about both methods.

View 1 Replies

Passing Variables Through Login Page?

May 6, 2010

I have gotten alot of help lately on my project and think I only have one more issue that I can't think of how to do. What i'd like to do is pass a login name and password from a Login.asp page to all of my other pages. So for instance if I have a successful login, I am taken to the Home.asp page. But i'm not sure how I can pass the LoginID used from Login.asp to the Home page. Ideally i'd like to use this information in the SQL connection strings, and to customize the Home page to show orders assigned to certain people that are logged in.

View 22 Replies

Web Forms :: Passing Page Variables

Jul 11, 2010

Function RenderTips(ByRef passTipName As String, ByRef passYear As String, ByRef passTipNumber As String) As String

View 10 Replies

Session - Saving Variables In Page?

Dec 25, 2010

I'm trying to convert a game I made (WindowsFormApplication) to an ASP.NET page.

My Problem is that I have a lot "private" variables in my WindowFormApplication and those variables are important for the game. But when after I Declare all my variables (in my Page_Load), they turn null no matter what I do(click a button, refresh the page).

Is there anyway to save my variables between buttons (other than Session, because I'd have to create like 6 more sessions)

View 1 Replies

VS 2010 / Define SQL Variables In Every Page

Jul 12, 2012

I define this variables as following in every page in project:

Code:
SqlConnection cnn;
SqlCommand cmd;
SqlDataReader reader;
cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString);

I lookup on way to facilitate this process i would define this variables one time in project.

View 3 Replies

C# - Declaring Global Variable/class In Application Scope 3 Ways - Which One Is Best

Mar 3, 2010

I am looking for differences between those 3 ways of using static class in asp.net application scope.
Will all of these point to the same class?

Which one is preferable >object< defined declaratively inside global.asax or static class ?

examples:

<object runat="server" scope="application" class="classname" ID="objID"></object>

VS

public static class classname {}

VS

Application("a") = new classname();

View 1 Replies

DataSource Controls :: Use Scope Identity To Get Newly Inserted Table

Feb 14, 2010

I have an SQL Server table named "Fields" with an autoincrement identity column "FieldID" as the primary key, an nchar column "Phrase" that textbox entries are to be stored in from a web page, and another column that is defaulted to null. The following is the recommended example on how to use Scope_Identity() to get a newly inserted table row identity value:

//C#
string query = "Insert Into Categories (CategoryName) Values (@CategoryName);" +
"Select Scope_Identity()";
int ID;
string connect = @"Server=.SQLExpress;AttachDbFilename=|DataDirectory|Northwind.mdf;" +
"Database=Northwind;Trusted_Connection=Yes;";
using (SqlConnection conn = new SqlConnection(connect))
{
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.Parameters.AddWithValue("@CategoryName", Category.Text);
conn.Open();
ID = (int)cmd.ExecuteScalar();
}
}

Obviously, this example uses a Categories Table in a Northwind database, which I do not have. So I am confused by how to adapt this example for my application. The following is my data context:

DataClassesDataContext db = new DataClassesDataContext();

Could you explain how I can adapt the example for my "Fields" table in my "EFMDB" database?

View 13 Replies







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