Use Server.mappath In Shared Method?

Dec 1, 2009

How can i use Server.MapPath in shared methos i tried something lile this [code]...

View 1 Replies


ADVERTISEMENT

Connection To MS SQL Server 2005 Database (using Server.MapPath)

Feb 29, 2012

I am tring to make the below application work with SQL Server 2005 Database Currently it works for test.mdb, which is in the same folder with the application. How shoud I modify the MapPath to work with SQL Server.

[Code]...

View 1 Replies

How To Use Server.Mappath

Jun 26, 2009

my code is Dim fs As FileStream =New FileStream("C:Documents and SettingsC100492DesktopDocssampleWSxmls" & GadgetName & ".xml", FileMode.Open, FileAccess.Read)

In the above code I have to change the phisical path(C:Document) with Server.mappath. let me know how to write the same code with Server.mappath. I have all xml files in my local application folder(folder name:XML).

View 3 Replies

Server.MapPath() Equivalant In Console App?

Feb 28, 2012

I am trying to get get the path of a directory that I have a template file in. ie in asp.net I use

Dim path as string = Server.MapPath("~/Reports/")) and then once I have the Reports dir I can do this
Using r As StreamReader = New StreamReader(path & "Template.htm")
Dim line As String

[code]...

That works great in asp.net but now I need to do the same thing in a console app. I have tried the function path = GetFullPath("~/Reports/") and instead of getting the absolute path to the Reports dir it returns /bin/debug/reports which is wrong. The file Template.htm is not in that directory.

View 3 Replies

Use Server.MapPath To Show All Files From A URI?

Dec 2, 2009

Ok i have a script that i have been working on for quite awhile and well its not working right i can't figure out how i would use Server.Mappath to show me all the file names from a URI. I have tried using a simple Directory Info but i get a Error "URI not supported" so i saw i can use Server.Mappath but how would i use this?

View 7 Replies

Use Server.MapPath When HTTPContext .Current Is Nothing?

Jan 20, 2011

I have some code that works fine when I need to delete some image files from a directory on my web server:

Dim ImageURL As String = dsImages.Tables(0).Rows(iImgRow).Item("ImageURL")
Dim physicalName = Server.MapPath(ImageURL)
oUpload.DeleteFileFromServer(physicalName, iAdid, iImgID)

[code].....

View 1 Replies

Load Contents From A Webfolder Using The Server.mappath?

May 2, 2009

i am trying to load contents from a webfolder using the server.mappath .. the server is giving me a error, and i have a feeling i need an import for the code to work...

View 4 Replies

.net - Why Can't Call Private Shared Methods From A Public Shared Method

Aug 25, 2011

I have a class like this:

[Code]...

It works, when I make getBar methods public, but I don't want to expose these unneccessarily. Why I can't call private shared methods from a public one in the same class is over my head. I'm using .net framework 4.0 in a web application.

View 1 Replies

[2005](Windows) Server.Mappath - Access A File

Feb 3, 2009

I am trying to access a file using the following

CODE:

However I am getting the following error: "Object reference not set to an instance of an object."

View 3 Replies

Shared Method Not Calling Shared Constructor

Aug 12, 2009

Given in the following language specification, for me at least, calling Db.Foobar() [In the following code] does not indeed call off to the Shared Constructors of the base classes. I am curious as to a) is this my own fault for doing something wrong or b) is this an error in the language specification[code]...

View 2 Replies

Can A Shared Method Be Multithreaded

Feb 28, 2012

As the question states, can a shared method of an object be multithreaded? I don't quite having threading down in my skillset, otherwise I would test myself. On the other hand, I am involved in designing class that could be part of a multithreaded application in VB.Net.

View 3 Replies

Use MyBase In A Shared Method?

Jul 7, 2009

I have a class that inherits from a base class (this contains a lot of common db related stuff amongst other things and is marked as MustInherit). I want to write a shared method in which I call a base class method, however the compiler gives me the message 'MyBase is only valid within an instance method'. This shared method is a logging method and will be used a lot within the app, I'm trying to avoid having to instantiate an object each time I want to call it.

Is it possible to access the base class methods from a shared method?

View 5 Replies

Using Shared Method For Getting DB Connection?

Aug 26, 2009

I have a utility class that creates & returns a db connection:
Public Shared Function GetConnection() as OracleConnection
dim c as New OracleConnection()
... set connection string...
c.Open()
Return c
End Function
Is there any risk of concurrent calls returning the same connection? The connection string enables pooling.

View 4 Replies

.net - Shared Form.ShowDialog Method?

Apr 18, 2011

I have a new developer that is calling Showdialog (in VB.NET) on a Windows Forms form without first creating an instance of the form.How is this possible? I don't see a shared method for ShowDialog...

I'm not crazy about this approach either as it seems to me that the dialog will not be disposed until the application exits.What am I missing? Is this a new best practice?OK, Form2 is just a blank form.Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles Button1.Click
Form2.ShowDialog()
End Sub
End Class

View 1 Replies

Generate A URL Within A Shared (static) Method In MVC.NET?

Sep 27, 2009

I'm creating a Shared (static) method in ASP.NET MVC so it can be used by any controller in my project. This static method needs to generate a URL. I think I need to use System.Web.Mvc.UrlHelper, but I can't figure out how to call it from within a static method.The constructor seems to want a RequestContext.

View 1 Replies

How To Create Extension To Shared Method

Jul 24, 2011

I like to create an extension method to Image.FromStream Public Shared Function FromStream(ByVal stream As System.IO.Stream) As System.Drawing.Image

With possibility to cancel processing like Public Shared Function FromStream(ByVal stream As System.IO.Stream, ByVal CloseTask As ManualResetEvent) As System.Drawing.Image

View 1 Replies

Ajax - Passing Instance To Shared Method In .NET?

Nov 4, 2010

I have been thrown in at the deep end with an existing VB.NET project at work. I have never used VB.NET before so I am struggling a little. Does anyone know how to solve the following.I need to pass an instance to client side and then pass it to a shared method in order to access instance methods from when the shared method.The starting point is a fileupload control within the HTML of my Contacts.aspx file:

<asp:FileUpload ID="DocUpload1" runat="server" onchange="CallMe();" />

The onchange event calls a javascript method, see below, this uses AJAX PageMethods to called a Shared method in my code behind This is the script code which is in my Contact.aspx file

[Code]...

If anyone knows the solution please could they update the code as I probably won't be able to understand if you just give a description. I just hope I am along the right tracks.

View 1 Replies

Asp.net - How To Get Classes To Expose The Same Shared/Static Method

Mar 4, 2010

I have a base class with several derived classes. I want all of my derived classes to have the same Public Shared (static) method with their own implementation. How do I do this? Is it even possible?

View 3 Replies

Call A Shared Method In A Loaded Dll Using Class Name?

May 8, 2012

[code]...

Dim ass as Assembly = Assembly.LoadFile("sample.dll")

Now, I want to call the shared method using the class name.

View 1 Replies

VS 2008 Shared Data Access Method?

Jul 31, 2010

use of the shared function, which returns a reference to a datatable to the calling code. While there a probably many debates as to the preferred use of ADO.NET objects, my question is about the Shared Method aspect. Note that the dataTable is declared within the Shared Function, so it seems to me you get a new one every time, yes?

Public Shared Function MyData() As DataTable
Dim ReturnData As New DataTable
'A silly example of retreiving some data into a datatable:
Using cn As New SqlClient.SqlConnection("SomeCOnnectionString")

[code]....

View 4 Replies

.net - Prohibit An Instance From Calling Shared/Static Method?

Aug 27, 2010

Is it possible to prohibit an instance of a class from calling a shared/static method?

For example:

I want to allow this:

ClassName.MethodOne()

But I want to disallow this:

Dim A As New ClassName
A.MethodOne()

The reason this is desirable is that in this case it is semantically confusing if an instance can call the method.

View 2 Replies

Dictionary Reset (Shared Method Of Popup Events)

Nov 21, 2010

There is a popup window which is rendered using xslt (no aspx page) on click of button, during this window load and close events I need to manipulate the text exist in the textarea of popup window. Having said I need to store the list words (key,value) for validation and spell check so I just declared a dictionary/hashtable object in common class (globals.vb) where i could store (add and retain values until I click close window, there could be couple of in turn calls to other methods of popup window) and manipulate as expected but whenever I reset the dictionary/hashtable (objDic.clear()) on popup load and close, it resets the concurrent users dictionary also.

Note :
1.Dictionary is declared as Public in Public Module (Globals.vb).
2.Dictionary manipulation happens inside the shared method (that is in turn calls to shared method of popup events).

View 3 Replies

Override A Public Shared Method In Derived Class?

Oct 8, 2010

Can we override a Public Shared method in derived class? If not why?

View 2 Replies

Visual Studio 2005 - Shared Method In Cannot Handle?

Oct 22, 2009

(I tried with this question but this code isolates the problem better. I have this code:

Public Shared Sub PopulateTextFields(ByRef stuffList As List(Of Stuff))
Dim aStuff As New Stuff
For Each aStuff In stuffList
DoStuff(aStuff)
Next
End Sub

[Code]...

View 3 Replies

Access A Class Variable Inside Shared Method (JSON)

Jun 20, 2012

Inside my .aspx I have some JSON code that looks like this:

[Code]....

Basically what I'm doing is pulling text from two labels on one page, and sending them to another page by calling the "doIt" function which looks like this:

[Code]....

Just so I'm clear, the "doIt" function and the JSON call are on two separate web forms. My problem is that with the "doIt" function being Shared, I can't access any global variables of the class. And if I remove the Shared, my JSON doesn't execute.

View 1 Replies

Local Variables In Shared Method Work Like Static Variable In C?

Aug 23, 2011

Will the list in this shared method keep its state throughout the life of the method? Or will a new list be created every time this method is called?

[Code]...

View 3 Replies

Moving Large Instance Method To Shared And Creating Stub?

Jun 5, 2011

If I have a very large function/sub in a class that is an instance method (i.e., not Shared), do I gain or lose anything by moving that to a shared method and then declaring a small stub method for the instance use?

I.e., I go from this:
Public Sub MyBigMethod(ByVal Foobar As String)
If String.IsNullOrWhitespace(Foobar) Then
Throw New ArgumentNullException("Foobar")
End If
[Code] .....

My thinking is I save on memory size per each instance of the object. Because each instance only has to lug around the stub method which handles calling the shared version and passing an instance of itself to the shared method so that it can do whatever it needs to do. But I'll wager that I sacrifice a very teensy amount of speed because of the added function call overhead.

View 1 Replies

Sql Server - Access A Shared Function From An Instance Of An Object?

Dec 28, 2010

The context of this question is that I am trying to debug performance issues (apart from the obvious ones I already know about and can find).I inherited a code base (VB.NET) for an ASP.NET app. This is an app that was developed way back in .NET 1.1 days, and was the first .NET app for a lot of the developers who worked on it.

In this code base is a class called DatabaseUtility that contains several Shared Public methods as well as non-Shared Public Functions and Subs for CRUD operations to the database (SQL Server).

It is common in my "BL" that a method creates an instance of the DatabaseUtility which essentially figures out what the connection string should be and opens a connection, as well as giving the developer a handle to the other methods contained within it.Dim utility as New DatabaseUtility()

Once I have that, I start to create parameters that I am going to pass to one of the methods in DatabaseUtility (like GetDataSet). There is a Shared method in my DatabaseUtility called CreateParameter which does essentially that. It creates a SqlParameter object so I can add it to a Parameters collection.

Now, the code base is littered with a lot of this:

utility.CreateParameter(...)However, because CreateParameter is a Shared method, I am not sure what is going on behind the scenes. I know because it is a Shared member that an instance of the DatabaseUtility is not created when I call it like this:DatabaseUtility.CreateParameter(...)

However, because I am calling it from an instance (utility), does that change the behavior at all?

View 1 Replies

MapPath To Root Folder?

Sep 22, 2009

This is my first post on the .Net Forums - I hope I don't break any rules in the first post,I'm trying to make a VB based .Net page return a file to the user from a location external to the website.The file itself is a software setup that needs to site outside the Web Directory, basically, the page needs to pick up this file and send it to the user when the page is loaded, I've done some research into the problem and it does seem that ASP .Net will not be able to let the user download files from outside the WebDirectory (in this case, WWWROOT).

Does anyone know if this can be done? I've pasted the code I'm playying about with below - but, I wouldn't be suprised if this is completely wrong

[Code]...

View 1 Replies

Method To "override" Shared Members In Child Classes

Mar 5, 2010

At the moment I'm trying to create a kind of model in vb.net which can be used to create/fetch database entrys.

I created a main class Model with a shared function to fetch the datasets, e.g. Model.find(). Now I'd like to create Classes which inherit the main Model-Class, e.g. a separate one for users: UserModel.find() => "SELECT * FROM users".

What I need now is to find a way to tell the Class which table it should use. I thought about an abstract String "table" which is a constant in each "child-model", but how could this be implemented as it's not possible to override shared members?

Edit: Maybe this will make it a little clearer what I mean:

Public Class Model
Public Shared _controller As Controller
Public Shared table As String

[Code].....

So I want a shared method which finds all database entries and gives back an array of instances of its own type, e.g. Model(). That's why I wanted to keep the find-method shared and not bound to an instance.

View 4 Replies







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