|
It sounds like vbServHandler is using Shared fields.
You should generally avoid Shared fields in ASP.NET applications unless you really know what you're doing. For example, the data in the fields will be shared across all requests from all users, which means you could easily end up showing data meant for user A to user B by mistake.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
They are NOT shared. I think it may be when a button control is hit on the page that the vbServHander is not getting re-initialized (vbServHandler variables still have data). I have done this:
1. By just click in the upload button on the vbMain button multiple times.
2. Clicking on the C# menu button (Upload) to reload the page.
3. Going back to the main page and clicking on the Upload button to reload the upload page.
4. Even refreshing the main home page via F5.
In all cases the constructor for vbMain (i.e. sub new) shows data in the vbServHandler variables.
I am programming around this (I actually think it is better) but just do not understand it.
|
|
|
|
|
If the variables are persisted between requests to your site, and they're not stored in application or session state, then either they're stored in Shared fields, or the instance of the containing class is stored in a Shared field somewhere.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
They are not saved anywhere.
If they are in some shared object then I do not know where it could be.
Here is the definition of the object I was checking in the Sub new of vbMain.
Public AccountCollection As Collection
in what I was calling vbServHandler. Real name is QBAPIV3Cl which is part of DLL QBAPIV3VS2013.
This is invoked via by vbMain
Imports QBOAPIV3VS2013
.
.
Public aQB As New QBOAPIV3VS2013.QBAPIV3Cl()
which is defined in a module within vbMain.
.
.
Which is referenced by the C# Web App
using vbMainDLL;
In the C# program it is defined as
vbMainDLL.vbMain vbMain;
vbMain = new vbMain(TheRealmID,TheAccessToken,TheAccessTokenSecret,
TheConsumerKey,TheConsumerSecret,
TheContext,TheDataService,
pOutReason: ref pOutReason);
The Sub New for vbMain has aQB.accountcollection.count
Referenced object has a value of nothing the first time.
then 121 every other time. I would expect a value of nothing each time.
The c# program has no references to the aQB class/QBOAPIV3VS2013.QBAPIV3Cl.
So what am I missing?
|
|
|
|
|
QuickBooksDev wrote: which is defined in a module within vbMain.
A Module is effectively a class in which every member is Shared . If your fields are stored in a Module , they they're Shared by definition.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Here is the class
Public Class QBAPIV3Cl
... No Module
Public AccountCollection As Collection
AccountCollection is the variable that I am checking for persistence.
It is references by the vbMain module as
Module Common which is a separate vb source file.
Module Common
..
Public aCL As New vbMain.QBAPIV3Cl()
So what you are saying since MODULE common is a MODULE everything in it is Shared/Static including all of aCL????
|
|
|
|
|
QuickBooksDev wrote: So what you are saying since MODULE common is a MODULE everything in it is Shared/Static including all of aCL????
Yes, that's correct.
A module has the same lifetime as your program. Because its members are all Shared , they also have lifetimes equal to that of the program.
...
All members of a module are implicitly Shared .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
So for a web app it last forever???
Is there a way of making a module non-Shared so I do not have to re-organize the program? Or what is the best way to have the module non-Shared?
|
|
|
|
|
Yes, in a web application it will last until the AppPool recycles.
There's no way to make a module non-shared. However, you might be able to get away with changing the field to a property, and adding code to retrieve the value from the current session if the code is running in an ASP.NET application. Something like this should work:
Imports System.Web
Imports System.Web.Hosting
Module Common
Private Const SessionKey As String = "Common::aCL"
Private aCLNonWeb As vbMain.QBAPIV3Cl
Public ReadOnly Property aCL() As vbMain.QBAPIV3Cl
Get
If Not HostingEnvironment.IsHosted Then
If aCLNonWeb Is Nothing Then
Set aCLNonWeb = New vbMain.QBAPIV3Cl()
End If
Return aCLNonWeb
End If
Dim context As HttpContext = HttpContext.Current
If context Is Nothing Then
Throw New InvalidOperationException("No current request.")
End If
Dim value As vbMain.QBAPIV3Cl = DirectCast(context.Session(SessionKey), vbMain.QBAPIV3Cl)
If value Is Nothing Then
value = New vbMain.QBAPIV3Cl()
context.Session.Add(SessionKey, value)
End If
Return value
End Get
End Property
End Module
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks will give it a try.
|
|
|
|
|
Dear all
I have a gridview in asp.net c#. Data is coming from DB. I need to add text boxes in every column and need to add multiple column auto filter option in it.
Please help. Thanks in advance
|
|
|
|
|
Can someone, please, please come to my rescue again?
I have been struggling with this code since last night.
On the markup page, we have 4 very important dropdownlists.
One dropdownlist has a controlId called tripType.
This dropdownlist has seven values. If a user selects any of the first five values, the dropdownlist with control id of from_city_and_state is visible. The other two dropdownlists, HourlyCharter and LongDistance are hidden.
If user selects Hourly from the tripType dropdownlist, from_city_and_state and LongDistance are hidden and the HourlyCharter dropdownlist is visible.
If Long_Distance dropdownlist is selected, Hourly and from_city_and_state are hidden.
By default, from_city_and_state dropdownlist is visible on page load.
So far, everything to this point works.
The issue is on codebehind.
If a user selects any of the first five values of the tripType dropdownlist as stated earlier, on codebehind, we would like to show one query.
If user selects Hourly value from tripType, we would like to show a different query.
Finally, if user selects Long_Distance, we would like to show yet another query.
So far, I am stuck on the hourly query.
If user selects any of the first 5 values of tripType dropdownlist, the query works flawlessly.
Other than that nothing else works.
Can someone please, please see what I am doing wrong?
Sorry for long explanation.
<asp:DropdownList ID="tripType" runat="server" class="select " onchange="ShowHideDiv();">
<asp:ListItem value="">--Select One--</asp:ListItem>
<asp:ListItem value="one_way_to_airport">One-way trip TO Airport</asp:ListItem>
<asp:ListItem value="one_way_from_airport">One-way trip FROM Airport</asp:ListItem>
<asp:ListItem value="round_trip_airport">Round trip involving Airport</asp:ListItem>
<asp:ListItem value="one_way_no_airport">One-way trip NOT involving Airport</asp:ListItem>
<asp:ListItem value="round_trip_no_airport">Round trip NOT involving Airport</asp:ListItem>
<asp:ListItem value="hourly">Hourly/Charter</asp:ListItem>
<asp:ListItem value="Long_Distance">Long Distance</asp:ListItem>
</asp:DropdownList>
<asp:DropDownList ID="from_city_and_state" runat="server" class="select " >
<asp:ListItem value="">--Select One--</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="HourlyCharter" runat="server" class="select ">
<asp:ListItem value="">--Select One--</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="LongDistance" runat="server" class="select ">
<asp:ListItem value="2">$2 per mile</asp:ListItem>
<asp:ListItem value="4">$4 per mile</asp:ListItem>
</asp:DropDownList>
Dim StrSQL As String = ""
Dim rs As OleDbDataReader
Dim val As String = tripType.SelectedItem.Value
If ((val = "one_way_to_airport") Or (val = "one_way_from_airport") Or (val = "round_trip_airport") Or (val = "one_way_no_airport") Or (val = "round_trip_no_airport")) Then
StrSQL = "select r.fare, r.tip, r.total from Rates r "
StrSQL += " Where r.city = @city "
'Response.Write(StrSQL)
'Response.End()
ElseIf val = "hourly" Then
StrSQL = "select distinct h.hourly, Switch([CarTypes] = 'Sedan', 55, [CarTypes] = 'Stretch (6 Passengers)', 75," & _
" [CarTypes] = 'Stretch (8 Passengers)', 90, [CarTypes] = 'Stretch (10 Passengers)', 95, " & _
" [CarTypes] = 'Stretch (12 Passengers)', 110 ,1=1, 10000)* h.hourly as Fares, " & _
" Switch([CarTypes] = 'Sedan', 55, [CarTypes] = 'Stretch (6 Passengers)', 75," & _
" [CarTypes] = 'Stretch (8 Passengers)', 90, [CarTypes] = 'Stretch (10 Passengers)', 95, " & _
" [CarTypes] = 'Stretch (12 Passengers)', 110)* h.hourly*0.7 as tip, " & _
" Switch([CarTypes] = 'Sedan', 55, [CarTypes] = 'Stretch (6 Passengers)', 75," & _
" [CarTypes] = 'Stretch (8 Passengers)', 90,[CarTypes] = 'Stretch (10 Passengers)', 95, " & _
" [CarTypes] = 'Stretch (12 Passengers)', 110, 1=1, 10000)*0.20*h.hourly as gratuity, " & _
" fares+tip+gratuity as total from HourlyRates h " & _
" inner join carType c on h.hourly = c.hourly Where h.Hourly = @hourly"
' Response.Write(StrSQL)
'Response.End()
End If
' Initialize Database Connection
Dim connStr As String = ConfigurationManager.ConnectionStrings("ALSConnectionString").ConnectionString
Dim conn As New OleDbConnection(connStr)
Dim cmd As New OleDbCommand(StrSQL, conn)
'We use parametized query to prevent sql injection attack
Dim p1 As New OleDbParameter("@city", lblPreviewfromCityState.Text)
Dim p2 As New OleDbParameter("@hourly", HourlyCharter.SelectedValue)
cmd.Parameters.Add(p1)
cmd.Parameters.Add(p2)
'Now open connection to the db
conn.Open()
'open recordset to receive db values
rs = cmd.ExecuteReader()
' This acts like the (Not RecordSource.Eof) in ASP 3.0 to loop and retrieve records.
While rs.Read()
' If rs("city") <> "" Then
Dim tipValue As Decimal = rs("tip")
Dim totValue = rs("total")
' Else
' End If
Dim tp As String = [String].Format("{0:C}", tipValue)
Dim tot As String = [String].Format("{0:C}", totValue)
lblTip.Text = tp
lblTotal.Text = tot
End While
|
|
|
|
|
Hi, i am using a soap service and getting this error "server did not recognize the value of http header soapaction", i got one solution to change namespaces of web service and i have changed but still getting this error.
changed from [WebService(Namespace = "http://tempuri.org/")]
To [WebService(Namespace = "http://50.63.156.139/ASMservices/SetupService.asmx")]
|
|
|
|
|
ASP.NET C# Dynamically add my selected item from dropdown to below with div tags. I'm new to ASP.NET. Someone please help me. Thanks in advance!!
|
|
|
|
|
Using jQuery for this is pretty simple. For what you're trying to do, you may want to refer to the following:
http://api.jquery.com/after/[^]
Basically, you're inserting new nodes into the DOM dynamically.
|
|
|
|
|
Hi,
I am very new to ASP.Net MVC, can somebody please help me in implementing excel like filer grid or table using ASP.Net MVC. Any links, or code snippet would help me. I am very new to ASP.Net MVC world. We are not planning to buy any tools so please the code should be from either plain ASP.Net MVC jquery and C#/VB.Net.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
|
Hi thanks buddy Anurag, I saw some of your articles also very interesting and useful. As I am very new to this ASP.Net MVC, I am the following question.
How can I use this .js file in my ASP.Net Application, can I just add it in my applications folder and reference it similar to ASP.Net Webforms?
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Yes, you can use it the same way and it will work.
However, from performance and code optimization point of view, you may wish to look into bundling and minification.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
I have several ASP.NET web pages that use a Master page. All of them have an AJAX update panel on the content page. I found this as the only workable solution to maintain scroll position because none of the standard code worked. And, all the pages behaved properly with this addition. I made some updates to a few content pages. One page is built with C# code. All others are VB. I made the same change to pages using the different code. All the VB code pages still maintain scroll position on post back. But the C# code page does not. I even rolled back to undo the change that I made, and it still rolls back to the top of the page on post back. Nothing seems to work. Am I missing something fundamental? I am using VS2010 with .net 3.5. I appreciate suggestions for a fix. Or commiseration.
Bobby
|
|
|
|
|
Page.MaintainScrollPostion = true
I stopped using that directive years ago. I think it worked years ago back in the early 2000's, but I think over the years it just faded away. I'm not sure about the mechanics of that directive, whether it just injects javascript on the page for the scroll position, I assume it does.
There are many posts on the subject, with thanks that fixed it and still not working, it worked but now it doesn't work. You have to use IE, worked in Chrome, but not Firefox.
I use the code behind example on line 1, with update panels, and all my pages maintain the the y axis scroll position during partial post back to the server. I've removed that line from several pages, and they still maintain the position.
I just spent about 20 minutes going through my programs and they all maintain scroll position. The programs with update panels.
Sorry I'm not much help here. I did some searching my seal using Google, and came up with all kinds of things here. Look into the Partial Postback on the update panel. The vertical size of the update panel, and the page source code, the HTML in your browser to see if there is any javascript associated with the directive.
I think the update panel is evil, and I replaced it with jquery and ajax calls to a web service, so scrollback position is not an issue for me anymore, over the last 5 years. Cost more to make, but provides a better user experience.
The directive
http://weblogs.asp.net/hosamkamel/maintain-scroll-position-after-postbacks-in-asp-net-2-0[^]
http://stackoverflow.com/questions/7394852/how-to-maintain-page-scroll-position-after-a-page-postback-in-asp-net[^]
Try this one
http://stackoverflow.com/questions/23836917/maintaining-page-scroll-position-after-updatepanel-partial-postback[^]
|
|
|
|
|
Thanks. I still haven't found the right solution. For now, I'll just let the page move back to the top. It's not very long. And I will leisurely search for a simple solution.
Bobby
|
|
|
|
|
It's a small detail of cosmetics, sort of
You might want to experiment with the update panel settings, and script manager settings,
That's why I highlighted the word partial post back. You may getting a full post back.
|
|
|
|
|
Thanks, I tried about everything with the settings, but still refuses to maintain position. I might experiment with just this one page and use jquery.
Bobby
|
|
|
|
|
if the page is public, private message me a link and I'll look at
|
|
|
|
|