C# - Ajax TimerControl And Instance Variables?

Jul 18, 2010

I've been having an issue trying to write to an instance member of my page class when using the Ajax timer control.

I've built a very simple crude example below which emulates the exact problem I'm having...

The code below executes a method called "UpdateText" every second using the timer control. Every time the method is called it increments a counter variable by one to illustrate how many times the timer control has made a callback.

Of course, in order to read the value of the counter onto the web page the label sits inside an update panel with a trigger associated to the timer.

Markup:

[code]....

If you run this you'll find it works, great but I don't want the 'loopCounter' variable to be static as this would apply to the whole application level and all users would be reading/writing to the same variable.

When I try to remove the static keyword, the loopCounter variable is no longer updated, it just stays at zero... There are no errors given in the code or in the browser (JavaScript).

I've found a temporary work around by using sessions instead which work nicely and remain in the context of a user but I prefer not to use sessions unless I really have to.

View 1 Replies


Similar Messages:

How To Use JQuery Ajax And PageMethods With Instance Variables

Oct 7, 2010

One reason we currently use UpdatePanels for doing our AJAX is because our BL and DA layers pass around the Page.User.Identity for authentication.

Is there a way to access this?

View 2 Replies

C# - Assign DTO Properties To Public Variables Or Call The Dto Instance Directly On Aspx Page?

Nov 3, 2010

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?

View 2 Replies

How To Access The Instance Variables Of One Class To Be Used In Another Class

Sep 15, 2010

Suppose we declare and define the variable in one class let say FirstClass and we want to use that variable in another class let say SecondClass which is outside of FirstClass .how to do this?

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

Visual Studio :: Vs Asp2008 Instance Cant Recognize SqlExpress 2008 Instance On Machine

Feb 6, 2010

vs asp2008 instance cant recognize the sqlExpress 2008 instance on my machine

I have wonder if you could try to help me with the fallowing issue:When trying to add a new sql server connection (local or remount) from VS(visual studio) 2008 express - on the add connection dialog

box: server name: are Empty!!
The vs couldn't point to any database, like dont recognize the sqlExpress 2008 instance i got on my machine.

1. Have tried to "play" with sa property's(from sqlS: Databases: security: login tree folder) and with the sql

s windows service: stop and restart
2. And so with the target db.
3.

On the services.msc
The sql server express the status is started.
The sql server agent status is disabled and don't have the option to start.
The sql server explorer status is disabled and don't have the option to start.

4. And so reinstalled the asp.

View 2 Replies

Session Variables Lost On Postback Using AJAX?

Jun 7, 2010

I'm evaluating using Ajax in a new project and so I've developed a simple web page to test a few things, however even the simplest task seems to cause my session to be cleared. I am using VS2008 with .Net 3.5 SP1 and the page is in my existing solution which has several custom handlers and modules in the web.config. Below is the code I'm using, it's a simple test which puts a variable into the session then on the buttons postback tries to get the same variable, however it always fails as the session is blank.

The Default.aspx code snippet
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" /> [code]....

View 1 Replies

Ajax - Pass Session Variables To A Hyperlink?

Mar 3, 2011

finding " how to pass sesion variables to a hyperlink in asp.net "

View 3 Replies

Simple Shopping Cart Using Session Variables Using AJAX

Feb 5, 2011

I know there are a million questions out there on how to implement a shopping cart in your site. However, I think my problem may be somewhat different. I currently have a working shopping cart that I wrote back in the 1.1 days that uses ASP.NET session variables to keep track of everything. This has been in place for about 6 years and has served its purpose well. However, it has come time to upgrade the site and part of what I have been tasked with is creating a more, erm, user-friendly site. Part of this is removing updatepanels and implementing real AJAX solutions.

My problem comes in where I need to persist this shopping cart over several pages. Sure I could use cookies, but I would like to keep track of carts for statistical purposes (abandonment stats, items added but not bought, those kinds of stats) as well as ser-friendliness, like persisting their cart so that if they come back it is remembered. This is easy enough if a user is logged in, but I don't want to force a user to create an account if they don't want. Additionally, the way we were processing orders was a bit, ehh, slapped-together. All of the details (color selected, type selected, etc) are passed to paypal via their description string which for the most part is ok, but if a product has selections that are too long for the string (255 chars i believe), they are cut off and we have to call the customer to confirm what they bought. If I were to implement a more "solid" shopping cart, we wouldn't have to do that because all the customer's choices would be stored, in addition to the order automatically being entered into the order processing system (they're manually entered into an excel spreadsheet. i know, right).

I want to do this the right way, but I don't want to use any sort of overblown software that won't really work with our current business model. Do I use a cookie to "label" each visitor to match them with their cart (give them a cookie with a GUID) across pages, keep their whole cart client side, keep the cart server side and just pull it from the db on each page refresh?

View 2 Replies

AJAX :: Session Variables Disappear On TabPanel Change?

Jan 19, 2011

As described above my session variables seem to be disappearing when i change the ActiveTabIndex of my TabContainer.

I call the session variable twice. The first time populates a div in "divResults", and then i switch to that tab, its only after the switch when i try to return the session variable again that its gone.

Is this really the case? I have seen it eluded to somewhere, and there was meant to be a fix coming out (this was 2006 or something).

Is there anything i can do here? I cant find any other reason why they would be disappearing other than this!

View 4 Replies

AJAX :: Reference Not Set To An Instance Of An Object?

Feb 19, 2011

I m Creating a Website Student Management And During Student Registration Getting this Error' Object reference not set to an instance of an object.'I m using LINQ Please Gv its Solution ASAP.my Code is :

protected void Button1_Click(object sender, EventArgs e)
{
{
StudentDataContext db = new StudentDataContext();
int flag = db.prcInsertStudent((Guid)Membership.GetUser(txtFirstName.Text).ProviderUserKey,txtRegNo.Text.Trim().ToString(), txtFirstName.Text.Trim().ToString(),
[code]...

View 1 Replies

AJAX :: Get A Sys.UI.Control Instance By DOM Element?

Jan 20, 2010

Is there a quick way to get the instance by Dom element.

My way is:

Base.find = function(element)
{
var c = Sys.Application.getComponents();
for (var i = 0; i < c.length; i++)
{
var e = c[i].get_element();
if (e == element)
return c[i];
}
return null;
}

View 3 Replies

AJAX :: Only One Instance Of A ScriptManager Can Be Added To The Page?

Sep 25, 2010

I am obviously confused by ScriptManager and ToolKit. Can you look at the code below?

[Code]....

View 4 Replies

AJAX :: Only One Instance Of A ScriptManager Can Be Added To Page

Jun 30, 2012

i use 2 file up load control in my page i used this code

<asp:ToolkitScriptManager ID="ToolKitScriptManager2" runat="server"></asp:ToolkitScriptManager>
<asp:UpdatePanel ID="Upbdt1" runat="server">
<ContentTemplate>
<asp:ModalPopupExtender DropShadow="true" ID="ModalPopupExtender1"

[code].....

I wrote these code twice in my page but when i run page this error occur..Only one instance of a ScriptManager can be added to the page. An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Only one instance of a ScriptManager can be added to the page.Source Error:  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

View 1 Replies

AJAX :: For Each Statement Cannot Operate On Variables Of Type 'AjaxControlToolkit.Accordion' / Getting Error

Mar 22, 2010

I am getting the above error, but i am not sure whats wrong with my code.

[Code]....

View 2 Replies

AJAX :: Multiple Instance Of FileUpload Not Working In Same Page?

Nov 11, 2013

i have to use two different Ajaxfileupload controls in a page .But when i upload file through second control the second event doesnot get fired(UploadComplete) everytime first event is fired.

<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
OnClientUploadComplete="onClientUploadComplete"
MaximumNumberOfFiles="10"
AllowedFileTypes="jpg,jpeg" OnUploadComplete="AjaxFileUpload1_UploadComplete" />

[Code]....

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

AJAX :: AutoCompleteExtender - Cannot Refer To An Instance Member Of A Class / How To Fix Error

Dec 7, 2010

I am using the Ajax AutoCompleteExtender control, and employing a public shared function to act as a web service without actually creating a web service. This approach works perfectly, however I would like to take this one step further and filter my query from a drop down list, however I am unable to accomplish this. Whenever I attempt to reference the drop down list from within the public funtion, I get:

"cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class."

I have found very limited documentation on resolving this error. Pretty much every solution includes removing the shared reference instead of handling it.

When I remove the Shared reference and just make it private, the AutoCompleteExtender ceases to function completely (i.e. functions a a regular textbox). Here is my code:

If you notice that I am not referencing the @YRQ parameter in my query, that is intentional. I will replace the subquery with that parameter when I am able to get this working.

View 2 Replies

AJAX :: Error In AjaxControlToolkit - Object Reference Not Set To An Instance Of An Object

Mar 28, 2011

I regularly run into the following error in my .NET 4.0 web application:

[Code]....

I found that the issue was already reported here: [URL], but there is no solution provided anywhere (at least, I didn't find it).

View 6 Replies

MVC :: "Object Reference Not Set To An Instance Of An Object." In Ajax Calls

Feb 25, 2010

I have a list of items on my page. There is a button in each row to edit that record. Record is being edited in jquery modal window. So I make an asynchronous call to server to display detail information about record without full page refresh.

User fills in data about that record and submits. If everything is ok, user is redirected back to page. But if validation fails I want to display that entry form again with errors.

If this call is done synchronously, users gets back form with filled data and errors, but without styles and javascript (because they are referenced from mail page) - that is ok

So I just wanted to refresh that modal dialog with asynchronous call. The problem is that Html.DropDownList or Html.TextBox extension methods fail with null reference exception. I have checked that real data are passed in as second parameter.

So I don`t understand where that null reference exception occurs, or what can I do?

The same call works if it is synchronous (Html.BeginForm) but fails if it is asynchronous (Ajax.BeginForm)

what can I do with it?

View 2 Replies

AJAX :: Call An "instance" Of Script From A Global Script

Sep 12, 2010

I have this pretty standard JavaScript:

[Code]....

Which is getting attached to a number of Label controls using the standard script descriptor syntax. The Javascript is behaving exactly as I would expect.

Now, I need to call the validate() function from elsewhere (I need to check all of the warnings that may be against any of the text boxes).

So, I have an array which contains all of the ClientId entries for the behaviours. I have tried this:
[Code]....

In that case, the $find returns Undefined.

View 1 Replies

AJAX :: How To Hide The "edit" And "delete" Links/Object Reference Not Set To An Instance Of An Object

Mar 12, 2010

I am using the ajax reorderlist control from the latest Ajax Control toolkit. Based on the logged on user, I need to hide the "edit" and "delete" links. They should be visible to admin, and not visible to others. I used to control this when I was using a gridview just by calling the column and setting it's visible property to false. I have tried using:

ReorderListMinutes.TemplateControl.FindControl("lnkDeleteAgendaItem").Visible =
False

ReorderListMinutes.TemplateControl.FindControl("lnkEdit").Visible =
False

This returns an error of the dreaded "Object reference not set to an instance of an object."

View 1 Replies

How To Use Application Variables

Jan 26, 2011

I cant figure out how to use the Application["myvar"] variable to store data for the application in asp.net 4.0 web app using c#. It say Application is not a known object and I can't for the life of me figure what to do a "using" on to expose it. I am in a static class at the time I cant use it. It seems to work in other units?

View 3 Replies

How To Use Variables With Function

Apr 27, 2010

I have this function that I want to pass the IP and port to and check for a connection. It works fine if I put "127.0.0.1" in the tcpClnt.Connect line. But if I pass the IP2 as shown in the line commented out, it tells me No such host is found. It's like it thinks "IP2" is the host name. How can I pass a variable in there?

[Code]....

View 4 Replies







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