Variable Be Shared Across Multiple User Or A Separate Variable Will Be Created For Each User?

Mar 7, 2011

I am having one doubt regarding the use of static variable in Asp.net pages.I am having one page say UserDetails.aspx.In this page, I have one static variable to store some data specific to a user. So, will this ?

public partial class UserDetails
{
static int numberOfReviews=0;

[code]...

View 5 Replies


Similar Messages:

Create Separate Variable Instant For Multiple Users?

Mar 4, 2010

I am using asp.net 2005 with vb and developing MCQ program.

I am reading question information from a database and array . the array is "public shared" one. the problem is when two users are login to the system both are getting the same array.

my reqrement is give seperate instances for the diffrent users.

as an example the first user can open paper with 25 questions and second user can open paper with 10 questions. First it display no of questions as 25 and when then second user open the site, then the first site also display the total no of question as 10.

I tried to use variable declareing with DIM statement then they are unable to access from other events.

View 1 Replies

VS 2008 Multiple Users Using The App Will The Variable Get Overwritten Each Time A User Calls It?

Jul 19, 2010

If I declare a public variable in my module then publish it out on the server...then have multiple users using the app will the variable get overwritten each time a user calls it?

View 1 Replies

C# - How To Edit User's Profile Variable (from Web.config) While Specifying User

Sep 24, 2010

This is how I edit the profile variables for a currently logged in user:

Profile.variablename = "this";

How can I do the same thing, but specifying the username whose profile variable I want to change, as opposed to just the currently logged in user?

Something like Profile.variablename.("username", "this") is what I'm looking for.

I'm using C# asp.net.

View 1 Replies

Variable Use Instead Of Shared?

Mar 25, 2010

I have the following variable which creates problem when i use multiples instance of the same web form. how i could what variables other than shared i can use to achieve this purpose?

Public strRoleType As String = String.Empty
Protected Shared isAreaSelected As Integer = 0
Protected Shared isStoreSelected As Integer = 0
Protected Shared isHeadOfficeSelected As Integer = 0
Protected Shared isRegionSelected As Integer = 0

View 2 Replies

Is Form Variable Should Unique For Each User

Jan 26, 2011

I use a form variable to sore USER_ID and pass it in various sub and function at the same page.Is form variable unique for each user? That is, if more than one user open this page at same time

View 6 Replies

Storing User-id In Session Variable?

Aug 30, 2010

When a use is logged in (Through open-id) we are creating a session variable named "UID" and storing the unique user-id in it. Later we are checking the session to see if the user is logged in. I think this is not the right way, but I could not force the team to change this, as I cannot show how this implementation can be cracked. why (If yes) this implementation is bad?

View 3 Replies

C# - Get Role Of User In A String Variable?

Jan 21, 2010

is there a way i can get the role in a string variable using the below commands....

System.Security.Principal.WindowsIdentity wi = System.Security.Principal.WindowsIdentity.GetCurrent();
System.Security.Principal.WindowsPrincipal wp = new System.Security.Principal.WindowsPrincipal(wi);


i need this for

FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, // version
UserName.Text, // user name
DateTime.Now, // creation
DateTime.Now.AddMinutes(60),// Expiration
false, // Persistent
role); // User data

as string role= wp.IsInRole();
but this is not right

View 5 Replies

C# - Can't Pass A Variable To A User Control?

Jun 17, 2010

I am using the below example code and have a problem where I can't pass the Request.RawUrl value into an object that extends the Control object (class Test below).When I use the line:

<Test1:Test runat="server" ID="testControl" Target="<%# Request.RawUrl %>"></Test1:Test>

I find that the Target property is never called.If I use this line instead:

<Test1:Test runat="server" ID="testControl" Target="<%# Request.RawUrl %> test"></Test1:Test>

the string value "<%# Request.RawUrl %> test" is passed to the Target property.f I use this line as explained in many posts online:

<Test1:Test runat="server" ID="testControl" Target="<%= Request.RawUrl %>"></Test1:Test>

the string value "<%= Request.RawUrl %>" is passed to the Target property.I need to get the value of Request.RawUrl passed to the Target Property of my Test control object. Does anyone have any ideas where I am going wrong?Control:

namespace Testing
{
public class Test : Control

[code]...

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

Web Forms :: Is Form Variable Unique For Each User

Jan 26, 2011

I use a form variable to sore USER_ID and pass it in various sub and function at the same page.

Is form variable unique for each user? That is, if more than one user open this page at same time, will app cause problem?

View 3 Replies

Creating A User Control With Variable Layout?

Oct 13, 2010

I have a user control which contains a number of child controls. I want to be able to change the layout of the control (i.e. change the markup surrounding the child controls) via a property of the user control, but I don't want to have to duplicate the child controls themselves. This precludes using, say, a MultiView with different versions of the layout in each view, since in that case I'd have to duplicate the controls. I'd also rather use markup than emit the code for the control directly (as you'd do in a server control).

To give a contrived example, say I have a label and a textbox. In one layout, I want the label and textbox to be contained by divs and laid out on top of each other. In an alternate layout, I want them to be contained side by side in a table.

Should I just go ahead and duplicate the controls between each view? It seems like a violation of the DRY principle, but I'm not sure if I have much choice. A partial solution would be making the views of a multiview into naming containers so that I could at least save myself the time of having to prefix the duplicate control IDs with something to make them unique.

View 3 Replies

Access Page Variable From User Control?

Oct 29, 2010

I have a property on a page called

public string productName { get; set; }

I want to access this in my usercontrol code behind. What's the right way to do it?Currently I am doing

((MyPage)Page).productName

But the user control is not compiling. My pagename is MyPage and I have also added a Reference

<%@ Reference VirtualPath="~/MyPage.aspx" %>

View 1 Replies

Setting Variable In User Control File?

Mar 3, 2010

I am trying to modify a .ascx file, to declare a variable. I've read that this is normally done in the code behind view, but I do not have access to the code behind, and this is a very small addition. We are using DotNetNuke, and in the .ascx file I have written

<script runat="server">
String foo = "bar";
</script>

And this causes the page to explode. I have some experience with PHP, but am very new to .NET. Is there a way to define a variable in a .ascx file in this way? Maybe I have not imported all the correct libraries at the top of the page?

View 7 Replies

Web Forms :: Can't Assign Values To Variable In User Control

Jun 17, 2010

I have a simple user control which toggles between the visibility of a few images depending on the UserId. When the page is loaded for the first time, the userID is being assigned correctly (I'm debugging). However, there are two other buttons on the page for filtering the type of users, they are perform their functionality via Ajax (not the toolkit, but the normal javascript ajax) When one of these buttons are clicked, the user control cant get the userid, it always comes up as Zero. Oh, btw, the usercontrol is in a DataRepeater, so it occurs for each of the user.. all the time.. or thats the Idea. I have several other pages like this, (none of them have ajax) and the user control has no problems whatsoever.

My User control code:

[Code]....

And the Data Repeater is something like this:

[Code]....

Here, Immediately after the userControl <ucAB:....> line, I am printing the userid just to see if its valid (by <%# Eval("UserId") %> and the user id's are valid too. I dont understand why the User Control cant pick it up on ajax postback?

View 3 Replies

Web Forms :: Access Page Variable From User Control

Oct 29, 2010

I have a property on a page called

public string productName { get; set;}

I want to access this in my usercontrol code behind. What's the right way to do it? Currently I am doing

(MyPage)Page).productName

But the user control is not compiling. My pagename is MyPage.

View 2 Replies

Web Forms :: Storing The User Details In A Session Variable In IE

Mar 16, 2010

Im storing the user details in a session variable(session["userid"]) while login.

[Code]....

Im using the session variables in other forms ,there im checking the session variable using the following code.

[Code]....

In this form im having 'export to excel ' button.When i click this button session variable becomes empty and redirected to the login page.(Im having this problem in IE only but in FF it works fine).

View 2 Replies

Web Forms :: Variable Width Image In User Control?

May 17, 2010

I am new to web design so bear with me. I have an .aspx page with a user control at the top that is basically a container for an image. It serves as a banner spanning the entire page. The lower part of the page is a left and right sidebar with a main middle section.

The image is simply some text at the left layered over a background that fades from blue to white, top to bottom. Image size is 90 p. high by 1000 p. wide. How can I get this image to vary width withing the control along with the rest of the page when rendered under different screen resolutions?

View 1 Replies

State Management :: Shared Variable But Specific To One Login?

Apr 28, 2010

I dont know if im writing in a right place. this is about class in App_Data (asp.net) folder that i want to user throughout system. but specifically for one user.

lets say userA login to the system. then system will use classUser
FillProperty and set variable like Name, Username, UserId (a property of his own, the modifier is
shared). the purpose is so that it can be used in any page. it behaves like
user.identity.name (when we want to call name of user that already authenticated)

I can do it fine. but once i test login with UserB in other browser, it change that shared variable with property of userB.what i want is, when A login, he will set the classUser with his data and data that called by him is his data. and when B login, he will do the same, but he will use his data without replacing userA data.here is the code :

-------------- CLASS -------------[Code]....

View 5 Replies

How To Use Session Variable To Display User Information After Authenticated Login

Dec 18, 2010

How can I use session variable to display user information after authenticated login like Address: 37, kings Road. Position: Secretary base on User ID

View 2 Replies

C# - Viewstate Variable Lost On User Control Loaded Dynamically

Feb 12, 2010

I have a problem with ViewState. I have an aspx page that has a treeview on the left and an UpdatePanel with an ASP.NET Panel inside on the right. It is in that inner Panel where I load and unload dynamically user controls. I use that update panel to load dynamically controls.

I also made a custom control for my user controls because I need to pass some values from page. On that constructor I use ViewState to store these values.

The first time I load the user control I call its constructor with parameters. When I reload that user control on each postback I use its normal constructor.

My problem is I the values I've stored on ViewState has become null on successive postback.

Update:

This is a piece of my user control:

public class MyUserControl : System.Web.UI.UserControl
{
private int PKId
{
get { return ViewState["pkId"] as int; }
set { ViewState["pkId"] = value; }
}
public MyUserControl(int pkId)
{
this.PKId = pkId;
}
...
}

I'm following this article to load controls dynamically: http://msdn.microsoft.com/en-us/magazine/cc748662.aspx#id0070065.

Second Update:
I also set the same control ID when I load the user control at first time and on each reaload.

Maybe I can use another method to store these values like input hidden fields or Cache. I've choosen ViewState because I don't want to overload server with Session values for each user.

Third update:

I load the controls with this code:

System.Web.UI.UserControl baseControl = LoadControl(ucUrl) as System.Web.UI.UserControl;
if (baseControl != null)
{
baseControl.ID = "DestinationUserControl";
PanelDestination.Controls.Add(baseControl);
}

And reaload with this code:

DynamicControls.CreateDestination ud = this.LoadControl(TrackedUserControl) as DynamicControls.CreateDestination;
if (ud != null)
{
ud.ID = "DestinationUserControl";
PanelDestination.Controls.Add(ud);
}

View 4 Replies

Visual Studio :: Access Master Page Variable From A User Control

Apr 10, 2010

I am using vb.net/asp.net 2005. I have a master page that displays a child content page. The child content page contains a user control that I created. In the user control I would like to access a variable that is set in the Master page.

View 3 Replies

Valid User Session Variable Not Found - Two Identical Error Messages

Apr 8, 2016

I am getting two identical errors message when I view my Web page in my browser:

Valid User Session Variable Not Found: System.NullReferenceException for this line:

Code:
Response.Write(Session("ValidUser").ToString & "<br />") <----------

and the same error for this line:

Code:
Response.Write(Session("strEmail").ToString) <-----------

This is the code in that page:

Code:
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Try
Response.Write(Session("ValidUser").ToString & "<br />")
Catch ex As System.Exception
Response.Write("Valid User Session Variable Not Found: " & ex.ToString & "<br />")
End Try

[Code] .....

This the page that users are redirected to after logging on and, after verifying their credentials at the log-on stage, should show 'Hello DonaldDuck@Disney.com, Welcome to my website'.

Do these errors mean that the user cannot be validated in the database?

View 9 Replies

Web Forms :: Calling Variable When Set In Separate Code File - Can't Work Out

Feb 8, 2011

I've done a search and read a few things, All i'm trying to do is set a variable in the code file and call it in the page file asp.net vb.net 3.5. I've tried like this in the code file:

[Code]....

And in the design part of the page:

[Code]....

But it says that name isn't declaired. What am I doing wrong?

View 7 Replies

Forms Data Controls :: How To Bind Dropdown On The Basis Of User Login (Session Variable)

Feb 16, 2010

I have dropdown and I have to bind that dropdown on the basis of user login so that when the page load the drop down should show only one item on the basis of user login and i may have use that dropdown item as a search parameter.I have a objectdatasource named TblFltReg having one of the fields named "Owner" which is the SectionId.

There is a table named TblSections having "SectionId" and "Description".User can be selected in a Session variable.I have another table "Users" having "UserName", "UProfile", "SectionId".Actually I dont know how can I get SectionId from Users table into Session variable.So I have two tasks: one to get SectionId into Session Variable and another is to show dropdown item on the basis of User login.Hope you understand.
How can I perform that task?

View 4 Replies







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