C# Global Variable Assigned Using Silverlight?
Mar 2, 2010
I'm pretty new to silverlight and asp.net but I have a strong background in c#. I am currently developing a c# asp.net application with silverlight elements. I was wondering if it was possible to have a user say click on an image that has a certain value associated with it and have that value access from a c# variable held outside the silverlight application.
View 2 Replies
Similar Messages:
Mar 7, 2010
[Code]....
The variable is assigned a value in another class like this:
[Code]....
View 1 Replies
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
Mar 2, 2010
The line "Return strLoc" below shows the green line underneath strLoc with the message "Variable 'strLoc' used before it has been assigned a value." In fact, it returns the value just fine to the calling module, so I'm wondering why it's giving this message and how to prevent it.
[Code]....
View 2 Replies
Mar 7, 2016
I am trying to access a user's login credentials to find out if they are an admin user or not. This way I can assign session variables to them and show certain aspects of the web page that other users won't see. I unfortunately keep getting this error when trying to dim a variable to assign the values too.
Variable Nuid is used before being assigned a value.
Variable AdminUser is used before being assigned a value.
Code:
Protected Sub checkAdmin_Click(sender As Object, e As EventArgs) Handles checkAdmin.Click
Dim strNuid As String = Request.Form("Nuid")
Dim cnString As String = ConfigurationManager.ConnectionStrings("snfTimeSystemConnectionString").ToString()
Try
Using cn As SqlConnection = New SqlConnection()
cn.ConnectionString = cnString
[Code] .....
View 4 Replies
Apr 20, 2016
I was working on my homework, making a website obiously, but I have a small problem with the griedview. I wanted to add a button on the end of the row, but I receive some error notifications and warnings too...
Code:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Partial Class Search
Inherits System.Web.UI.Page
[Code] ....
There is this error too:
SeverityCodeDescriptionProjectFileLineSuppression State
ErrorBC30518Overload resolution failed because no accessible 'Add' can be called with these arguments:
'Public Overloads Sub Add(column As DataColumn)': Value of type 'ButtonField' cannot be converted to 'DataColumn'.
'Public Overloads Function Add(columnName As String) As DataColumn': Value of type 'ButtonField' cannot be converted to 'String'.GIPH:GIPSearch.aspx.vb31Active
View 9 Replies
Dec 28, 2010
I'm fairly new to ASP.net development as may have been noticed by some of my other posts and so here goes another one.I have a web page in which I allow users to enter data that will be used to populate a database and then graph data based on the information that was saved in the database. I have 10 sets of criteria that the user can enter and as they enter values for each individual set, I make sure all the parameters are filled in and set a variable called blnParm1, blnParm2, blnParm3, etc. Anyway, as each DropDownList box fires off an event the values of my blnParm variables is reset because each time the event is fired the page is PostBack therefore my variables are redeclared. I know the page is being PostBack because each of the DropDownList boxes have AutoPostBack set to true. I had to do this so that I could get the OnSelectedIndexChanged event to fire for each of the DropDownList boxes. So, how do I preserve my variables through this PostBack or how do I get the events to trigger without calling AutoPostBack?
Some more info, my variables are declared globally in my aspx.cs file as private bool. The code is working like it should as far as populating drop downs dynamically based on other data input by the user, the controls all have their values preserved as the page is PostBack.
View 2 Replies
Jul 18, 2010
[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.
View 2 Replies
Sep 10, 2010
xamount is receiving this message on the last line. The session is being set in the previous page. Is there a way to resolve the message or should I just use a previous page postback
[Code]....
View 9 Replies
Dec 9, 2010
can we grab a global variable or Session or View State variable in the javascript or using jquery?
View 2 Replies
Jan 13, 2010
----> I have datatable which is passing to another page in session variable.
----> Now on another page i take the session variable into datatable.
datatable ds_table = new datatable();
ds_table = (datatable)session["table_value"];
----> so problem, is that , when i filtering some rows from ds_table . that taking effect in the session variable. if some rows deleted from ds_table. then it is also deleted from session variable.
----> so, anyone tell me why is this going to happene?
View 3 Replies
May 25, 2010
I have the dataset. in this i am having total 20 tables with huge amount of data..I want use this data over all the page..so where i can keep this data..
before i used viewstate but the viewstate data is render to page every postback ..so this time the page size is increasing(interanlly viewstate is rendered to page)..so performence wise it was very slow..
Now i change my logic insted of viewstate to i used Globel Dataset on Page Level.. now the performence wise better than viewstate..
i used Like shared dsControls as Dataset at top of the page..so every time i use this dataset..
my quesation is session is better or Globel variable is better way use in my situavation..
View 3 Replies
Mar 11, 2010
Is it possible to use global variables in C#? I'm coming from mainly a PHP background so variables are either accessible everywhere or just a global definition away.
My main issue is I have a User class that I built myself to wrap around the current users table on my company's database. I am defining it in the MasterPage but can't seem to access it from the actual pages (I don't know if there's a better word to describe them but they are the pages that inherit the styles and format from the MasterPage) Any general tips or implementation practices for me?
EDIT: here's some code snippets of what I'm trying to do:
Site.master.cs
public partial class SiteMaster : System.Web.UI.MasterPage
{
public User user = new User();
}
logout.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="logout.aspx.cs" Inherits="logout" %>
<%@ MasterType virtualPath="~/Site.master"%>
logout.aspx.cs
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
User user = Master.user;
}
}
View 7 Replies
Dec 28, 2010
I have a process within my MVC 2 application that takes a large amount of time and alters many rows in the database in the process.
There is a chance that two or more users could attempt to perform this action at the same time, which would lead to undesirable effects.
Is there a way to set a global flag somewhere within asp.net that I can check against all requests to see if the action in question is currently being executed? (a bit that I flip prior to running query, and then then flip back on completition)Or is there a better way of handling this situation?
View 2 Replies
Nov 13, 2010
I want client access a data center but without use database , so I want my web app can retain a global or Application session variable, that contains the data, every client can access the same data... I am try to declare in golabl, but seem it only can store String but others ..
View 5 Replies
Jan 16, 2010
I am having some trouble with my web service. I want to make a variable that will be the same for each thread running. To be specific, my program is that user 1 goes on my page and types something into the textbox and that user 2 can see what user 1 is typing into the box. its sorta like google wave. The problem is that when i run it, the variable's value does not go to user 2 and instead another instance of that variable is created.
View 18 Replies
Mar 18, 2011
I want to declare a Dictionary<string, object> variable but don't know where/how to. The values in the dictionary will be objects from the Page (ListBoxes, DropDownLists, etc) so I can't exactly create a class somewhere else. Is there any way I can make this variable accessible from each method in the codebehind?
View 5 Replies
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
Feb 27, 2013
How do I need get the variable in the master page?
1. after Login.aspx get the information of the user
2. redirect to home.aspx
3. in home.aspx, view the info like Label1.text ="Welcome " + varUser;
4. Label1 is located in the master page
5. this varUser will display in all my pages
6. I don't want to use the full Session["var"] (because of expiration)
*in short I just want to get the var in the master page everytime I load a new page
(WITH MULTIPLE UNIQUE USERS)
View 1 Replies
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
Jul 15, 2010
get the value of Global variable in javascript example var a="priti"so want to access "a" in code behind as it's global varible
View 2 Replies
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
Jan 7, 2010
I need to use a global variable as a parameter for the SqlDataSource element. I capture the user Name when he/she logs in:
Public UserName As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
UserName = Page.User.Identity.Name
End Sub
Then, I need to use the UserName to search the SQL DB and show only logged user personal information.
SelectCommand="SELECT * FROM [Member] where [UserID]= UserName"
What is the sintaxe to use a global variable into the SQL Select Command?
View 10 Replies
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
Oct 31, 2010
I have to define a global and unchangeable variable in a web page. I used static variable but its content is the same for all users that use the page and it is bad. I dont want use Session variable.
View 5 Replies