Advantages/Disadvantages Of Public Shared Functions

Jan 8, 2010

We have an application that has quite an extensive APP_Code directory (about 150 functions). The functions are split across multiple files and then classes and namespaces.

On numerous pages we have to create numerous instances of the classes to be able to access the functionality, which can get very repetitive and means we're repeating code on every page declaring the instance etc.

As far as I can tell, a way to navigate this issue, is to make the functions Public Shared (as opposed to just Public functions).

View 5 Replies


Similar Messages:

What Are The Advantages And Disadvantages Of Using Caching

Jun 30, 2010

What are the advantages and disadvantages of using caching in an asp.net application?

View 2 Replies

IIS Web Garden Advantages / Disadvantages?

May 17, 2010

When do you need IIS Web Garden feature. What's pro's and con's?

View 2 Replies

Advantages And Disadvantages Of Using Application Variables In Web Applications?

Jun 8, 2010

I haven't used the application variables in my asp.net web applications. Im using asp.net2.0. Is there any disadvantages of using applicationvariables.

View 1 Replies

Architecture :: What's The Advantages / Disadvantages Of Explicit Interface Implementation

Jul 19, 2010

I am searching for the advantages and disadvantages of the explicit interface implementation

View 1 Replies

SQL Server :: Making Foreign Key Null Able - Advantages / Disadvantages

Nov 17, 2010

I would like to know if the forieng key should be nullable or not. We shuld struggle for not making it nullable as much as possible or it doenst matter.

View 1 Replies

Forms Data Controls :: Advantages/disadvantages Of Dataset And Databinding?

Aug 18, 2010

what are the advantages/disadvantages of dataset and databinding?

View 3 Replies

Private Shared Vs Public Shared Vs Protected Shared

Jan 5, 2010

let me know what does these access modifiers means.private shared vs public shared vs protected shared

View 5 Replies

How To Access A Module Or A Public Class With Public Shared Members From Inline Vb Code

Feb 10, 2011

I can access a module from code behind but not from the aspx page in inline VB code <% ... %>.

I know its got to be something simple but I can't seem to find the answer anywhere.

View 1 Replies

Web Forms :: Shared Functions And Classes Error

Oct 4, 2010

I have some code in my new asp.net app that I need to share. So i created a shared class called
"utilities.vb" and put it in the APP_CODE folder. There is a function I have in there that pulls a person's image based off of their MemberId.

[Code]....

And I can call this function from my page using utilities.FcnGetMemberImage(). Ok, so all good so far until it complains about...

"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"

when referring to the Server.MapPath()

But the problem is that if I don't make it a Shared Function, I can't access it from my other pages. But if I do make it a Shared Function, it throws this error. The fix is supposed to be that I either don't share the function, or

"add the shared keyword to the member declaration", according to Microsoft at
http://msdn.microsoft.com/en-us/library/xfsswe45.aspx

But I'm not exactly sure how to "add the shared keyword to the member declaration" or what this means exactly and how this might affect other parts of my code?

Or is there a better way to work around this dilemma?

View 3 Replies

Calling Other Functions From A Shared (or Static) Function

Aug 20, 2010

I get this error: 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.

Partial Class _Default
Inherits System.Web.UI.Page
<WebMethod()> _
Public Shared Function ParseData() As String
Dim value as string = GetValue()
End Function
Private Function GetValue() as String
Return "halp"
End Function
End Class

I know it has something to do with the fact that the first function is shared and the second function should probably be Public as well but I don't fully understand the reason behind it. Probably not relevant but I'm calling the web method from some javascript.

View 1 Replies

Vb.net - Architecture Specific To Shared/Static Functions?

Apr 30, 2010

If for example you have a function Public shared function GetStockByID(StockID as Guid) as Stock Is that function common to all current users of your application? Or is the shared function only specific to the current user and shared in the context of ONLY that current user? So more specifically my question is this, besides database concurrency issues such as table locking do I need to concern myself with threading issues in shared functions in an ASP.Net application?In my head; let's say my application namespace is MyTestApplicationNamespace. Everytime a new user connects to my site a new instance of the MyTestApplicationNamespace is created and therefore all shared functions are common to that instance and user but NOT common across multiple users. Is this correct?

View 2 Replies

Public Shared Properties - Where Are They Stored

Oct 4, 2010

I have the following code in a class in which I call from different pages, I wanted to know where this info is being stored at as I can see it from different pages.

[Code]....

Also, is this saved on the browser session? IIS? will whatever being set from 1 user be affected by every other user on the site?

View 5 Replies

C# - Will Static Public Variables In App Get Shared With Other Users In The Same App

Nov 11, 2010

For reasons I would rather not discuss, I need to create a custom authentication system for my app. I was just reviewing the system and am having some doubts if my solution is thread safe. My goal was to create a solution that would allow my app to authenticate a user one time and that users authentication info would be shared by all master pages, pages, classes, user controls, etc that are used. (But not share the same info between users) Here is my setup: PageHttpModule.cs - this is added to the web.config as a httpModule.

public class PageHttpModule : IHttpModule
{
public void Init(HttpApplication app)
{
app.AuthenticateRequest += new EventHandler(OnAuthenticateRequest);
}
public void OnAuthenticateRequest(Object s, EventArgs e)
{
CurrentUser.Initialize();
}
public void Dispose() { }
}
CurrentUser.cs
public static class CurrentUser
{
public static bool IsAuthenticated { get; private set; }
public static string Email {get; set;}
public static string RealName {get; set;
public static string UserId {get; set;}
public static void Initialize()
{
CurrentUser.AuthenticateUser();
}
Note: this is a scaled down version of my authentication code.
public static void AuthenticateUser()
{
UserAuthentication user = new UserAuthentication();
user.AuthenticateUser();
if (user.IsAuthenticated)
{
CurrentUser.IsAuthenticated = true;
CurrentUser.UserId = user.UserId;
CurrentUser.Email = user.Email;
CurrentUser.RealName = user.RealName;
}
}
}
UserAuthentication.cs
public class UserAuthentication
{
public string Email { get; set; }
public string RealName { get; set; }
public string UserId { get; set; }
public bool IsAuthenticated { get; private set; }
public UserAuthentication()
{
IsAuthenticated = false;
Email = String.Empty;
RealName = String.Empty;
UserId = String.Empty;
}
public void AuthenticateUser()
{
//do some logic here.. if the user is ok then
IsAuthenticated = true
Email = address from db
UserId = userid from db;
Realname = name from db;
}
}

I have tested between 3 different browsers and it seems to work fine, but I am still learning and don't want to make a huge mistake. If my logic is totally wrong, then how should I do it so I dont have to put user lookups on every page directly?

View 4 Replies

Web Forms :: Unable To Get The Label Text Into Public Shared Function

Jan 12, 2010

I am using the following code for slide show of AjaxToolkit. It works. But I wanna get the label1.text as picture name But I cannot do it in public shared function ! How can I do that !

[Code]....

View 6 Replies

Web Forms :: How To Use Scriptlet To Access Public Class's Readonly Shared Property

Aug 14, 2010

I have made public readonly shared properties in my class.

I want to acces a property's value in .aspx page. As i think that is possible through scriptlet like this

<%= ClassName.Propertyname %>

But its not working .Where i am wrong ?

View 5 Replies

Forms Data Controls :: Pass A Texbox.text To A Public Shared Function?

Jan 12, 2010

I have a gridview that is dynamically created and have finished all but one problem - I need for my code that is within a Public Shared Function to access a textbox string - In the below I need myinput to return the string so that my query's can use the variable - the below shows: 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.

If I remove the "Shared" the error goes away however it crashes other parts. (if I hard code the text then all works as expected)

[Code]....

View 3 Replies

Vb.net - Declare A Public Variable And A Public Sub In An Aspx Web Page?

Aug 26, 2010

How do declare a public variable .aspx web page that can be used in all the pages within my web application? And/or create a Public Sub?

View 3 Replies

C# - Disadvantages Are There To Use Innerhtml To Populate A Div Tag?

Feb 2, 2011

what disadvantages are there to use inner HTML to populate a div tag consider, all scenarios possible.

View 2 Replies

Public Static Variable Declared In Public Static Class MyGlobals In A 'Code File' Template?

Jan 27, 2011

I have a question about C Sharp ASP.NET:Is there a difference (in code speed, resources) between:public static variable declared in public static class MyGlobals in a 'Code File' template;and the variable declared in a normal 'Class File' template;I use this variable in 2 different Class Files and also in _Default Page codebehind cs file.In fact in my case I need about 20 global variables of type List<string>.

View 9 Replies

AJAX :: Any Disadvantages If Use More UpdatePanels In Application?

Feb 16, 2010

is there any disadvantages if we use more UpdatePanels in our application.

View 4 Replies

Whats Are The Major Disadvantages Of Using Membership API

Jun 5, 2010

Whats are the major disadvantages of using Membership API? And when should i consider relying on using manual coding?

View 1 Replies

Disadvantages Of Enable Content Expiration In IIS?

Nov 5, 2010

What may be the disadvantages of enable content expiration in IIS 6 ?

View 1 Replies

DataSource Controls :: SqlDataSource Control Disadvantages?

Apr 4, 2010

what is the disadvantages of using SqlDataSource Control? apart from flexibility and more control on the retrieved data ;why most of the web developer prefer using code behind (db connection) instead of SqlDataSource Control?

View 5 Replies

What Advantages Does PHP

Oct 21, 2010

I have opened a large web project on elance for a social network. I got over 30 bids on my project and many of the providers recommended php even though they had .net knowledge. many have said that php with drupal has many advanteges over the .NET framework but did not say what they were. Its hard to believe that a scripting language has advantages over a compiled language.

View 6 Replies







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