|
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
|
|
|
|
|
I haven't uploaded the misbehaving page yet. The one currently on the site behaves properly. I have a few more changes yet to complete to the site. When I upload the modified pages, I'll send you the link for your inspection. Thanks for your help.
Bobby
|
|
|
|
|
I loaded the new web pages. You can have a look at the one that doesn't maintain scroll position. www.bobby-strain-group.com/Budget/calcCylinder.aspx
Bobby
|
|
|
|
|
You should be able to calc in jquery or javascript
on the button, OnClientClick="calculate_numbers(); return false;"
I haven't been able to figure out why, with the current code, but the button does fire a postback to the server.
I'll keep looking.
|
|
|
|
|
hi friends, i have created a asp.net website with mysql as database. then i have create a dump file of my database. now i want to connect the website with the dump file.
dinu
|
|
|
|
|
Well, you need to connect to a database for the website.
I don't get it.
You have a database that works, why not connect to that?
A dump file is for storing or transferring the database to another server, not to connect to.
If you want to recreate the database, then use the MySQL Manager, I forget what it's called, and create a database, and run the dump file to create the so called tables and columns, and load the data, then connect to that.
|
|
|
|
|
Hi, Actually i want to run that website in another system. and that system has not mysql database. so can i use the dump file
so with out the mysql. i can run my website in other system
|
|
|
|
|
As developers, we do that all the time.
But you have to create a database server to connect to, and create a database on that server.
Then take the dump file, and load it up, so you have an exact copy of the database, minus the credentials and that sort of stuff.
Do you get it?
|
|
|
|
|
Thank u. but when we use the sql server as a database then we are using the .mdf file from the App_data folder. but at the point of mysql is it possible?
|
|
|
|
|