Cannot Refer To An Instance Member Of A Class From Within A Shared Method ....
Nov 9, 2010
I have a public shared function and I'm trying to access the values of a text box and a session variable.
I'm getting the 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."
Is there any way I can get to the values in the textboxes or session variables from within the method?
[code]....
View 2 Replies
Similar Messages:
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
Mar 2, 2010
how to refer shared function in a class , this function itself inside same class
public class cls1
Public Shared Function getDBDate(ByVal pDate As Date) As String
Return Format(pDate, "yyyy-MM-dd")
End Function
Private Function GetDb_Format(ByVal pDateString) As String
Dim d As Date = Me.ParseDate(pDateString)
Return clsDate.getDBDate(d)
End Function
End Class
can i have any other way to use getDbDate function
View 2 Replies
Feb 15, 2011
I'm using MVC 2 application and it works well back then, but after I restart VWD2010 these errors comes up. [:(]
(1)
BC30456: 'RenderPartial' is not a member of 'Html'.
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
<%Html.RenderPartial("/Views/Shared/EditEmployee.ascx")%>
'DropDownListFor' is not a member of 'Html'
<li>* Choose Country
<%= Html.DropDownListFor(Function(model) model.country, Nothing, New With {.class = "highlight"})%>
It's odd because all instance of 'Html' at Views are getting such errors. I did build/rebuild/clean the project but still the same errors.
View 1 Replies
Nov 7, 2010
i have a SortedList.The value of which is a Cart Object that stores a Product object consisting of properties.
i wish to set the datasource to the Product object.
so how can i refer to the Product object?
View 6 Replies
Oct 4, 2010
I am working on converting a project from C# to VB and am facing this weird issue. 1 page cannot compile and I get the reference error, but the weird thing is that the compiler shows the error as coming from ASP.NET generated code. Visual Studio shows me that error is coming from my ASPX page. I cannot seem to figure out why or where this error is occuring. Also if I take the inherits attribute out I don't get the compilation error. The code in aspx page is below:
[Code]....
View 18 Replies
Apr 22, 2010
I am using VS2005, and a newbie at table adapters, DAL & BLL. I have a single dataset (in DAL) and 2 classes (in BLL) named Class1.vb and Class2.vb.
When I try to call a function from Class1 within Class2 I get the error "Reference to a non-shared member requires an object reference".
Here is a sketch of my code structure:
[Code]....
View 3 Replies
Oct 8, 2010
I do not receive this error when I open my website application in vs 2005. When I open in vs 2008, I get this error. What gives?
These lines are underlined in blue:
[Code]....
Businesslogic area is imported into each of 3 pages with this line.
View 9 Replies
Jun 30, 2010
I have a class instance which is created by using Activator.CreateInstance() method. That class instance contains helper methods which are frequently used throughout the application. In order to avoid creating the instance multiple times, I'm just thinking about implementing an appropriate caching mechanism. The following consideration should be taken into account:
1) I can't use static class and methods.
2) There are around 6 instances (1 instance per class) per App Domain.
View 4 Replies
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
Mar 4, 2011
I'm using Facebook SDK C# Library in Asp.Net 3.5 Application. When I'm trying to compile the code below give me the errors. As I know dynamic type using in 4.0 framework. So is anyway to rewrite it in order make it work? I have a reference to System.Core 3.5 but it's still not compiling
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params.AllKeys.Contains("signed_request"))
{
var result = FacebookSignedRequest.Parse(FacebookContext.Current.AppSecret, Request.Params["signed_request"]);
dynamic signedRequestValue = result.Data;
this.RegistrationData = signedRequestValue.registration;
}
else
{
Response.Redirect("~/");
}
}
protected dynamic RegistrationData { get; set; }
Error 1 Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference to System.Core.dll?
Error 2 Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference to System.Core.dll?
View 1 Replies
Oct 19, 2010
I have a serious problem since yest, i have a grid and i have to pass parameter to datasource of grid during run time...i tried this way in grids it worked.yest wen i try to create a new grid and pass parameter thru onselecting method of grid. i faced problem.
here's my code:
[Code]....
when i run this code im gettin error that SQLDATASOURCE1_selecting is not a member of asp.webform1.aspx..
View 2 Replies
Mar 14, 2011
Given an instance of a control SomeControl that is in a some file (could be a usercontrol/ascx, or an aspx) how can I get a reference to the class to which it belongs?
In a usercontrol, SomeControl.NamingContainer seems to be reliable.
In a page that inherits from a MasterPage, this will return a reference to the ContentPlaceHolder, not the actual class that defines the aspx. What I would want in that case is SomeControl.Page
Parent will return the parent control in the heirarchy so isn't much use.
Is there any method for getting this directly regardless of what kind of thing it is?
View 2 Replies
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?
View 3 Replies
Jul 21, 2010
I've created a nice menu class and used it in my MasterPage like "using My.GeneralRoutines".This class is working well and everything is fine UNTIL I want to access this same instance of that class that was created at MasterPage level on "a_page.aspx.cs" (this page is using the MasterPage like :)
[Code]...
View 8 Replies
Jan 21, 2011
I would like to know how to relate my shared class to my web User controls?? For example say I add a new class my project to run a game. How do I get infomation I need from my web controls to be used in my class.Say my user select easy for the difficult mode on a radio control. I want the class to be able to see that the user control has been set to easy or have the class modify values for my web controls
View 1 Replies
Oct 18, 2010
I have an ObjectDataSource that I want to perform updates using a business entity i.e. Type="Object"). Since the values for the entity are within a user control, I have stored a reference to the control in Session and in the updating event, set the new instance to the value of the entity from the user contol property (which also pulls values from the form viaother properties of the control):
Protected Sub MasterDataSource_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles MasterDataSource.Updating
Dim entity As New Login()
Dim accountControl As AccountInfo = TryCast(Session("AccountCtrl"), AccountInfo)
entity = accountControl.Entity
e.InputParameters.Add("entity", entity)
End Sub
And here's the markup for the datasource:
<asp:ObjectDataSource ID="MasterDataSource" runat="server" EnableCaching="true" CacheDuration="10"
SelectMethod="SelectAll" UpdateMethod="Update" TypeName="Data.DAL.LoginDAL">
</asp:ObjectDataSource>
My question is, how can I get the update method to pass this entity to the update method in my BLL class? It seems the Update method requires an ID or reference to the original object to use in determining whether any changes have taken place, but I don't really want to do this. In other words, I just want to use the Update event on my ObjectDataSource to pass my entity to the method ("Update") I set as a property and then let this business method handle the update of the data. Shown below, is the BLL update method I want to call:
Public Overloads Function Update(ByVal entity As Login)
If entity Is Nothing Then
Throw New ArgumentNullException("entity")
End If
MyBase.Update("UpdateLogin", entity.Username, entity.Password, entity.FirstName, entity.LastName, entity.Role, entity.Region, _
entity.Email, entity.Title, entity.TierID, entity.Street, entity.City, entity.State, entity.Zip, entity.Mobile, entity.Phone, entity.Fax)
End Function
When I try to call this as it stands now, I get an error: ObjectDataSource 'MasterDataSource' could not find a non-generic method 'Update' that has parameters: ID, entity. Previously, I'd set up a long list of parameters of basic data types (string, int, boolean), but this is rather cumbersome and I was hoping to use an entity for this (FYI, I also got the same type of error when I tried this approach, but with the ID as the
last parameter in the list). Perhaps what I'm doing here is atypical to how the ODS is normally used?? Has anyone done something like this successfully?
View 1 Replies
Jan 5, 2010
let me know what does these access modifiers means.private shared vs public shared vs protected shared
View 5 Replies
Jul 1, 2010
I'm trying to implement a view tracking web service on my website. I'm using JavaScript because I want to exclude any search bots from my tracked views. The problem is I'm getting a "Unknown web method" error when I try to use jQuery to post to the web service I've created.
$(document).ready(function() {
$.ajax({
type: "POST", [code]...
The error is an ASP .NET error: Unknown web method TrackItemView. Parameter name: methodName.I've done this hundreds of times (seemingly), but I just can't see what I'm missing. I'm sure it's something small...
View 1 Replies
May 28, 2010
In page behind classes I am using a private and shared object (list<client> or just client) to temporary hold data coming from database or class library. This object is used temporarily to catch data and than to return, pass to some function or binding acontrol. 1st: Can this approach harm any way ? I couldnt analyse it but a thought was using such shared variables may replace data in it ?2nd: Please comment also on using such variables in BLL (to hold data coming from database) where new object of BLL class will be made everytime.
[Code]....
View 4 Replies
May 28, 2010
In page behind classes I am using a private and shared object and variables (list or just client or simplay int id) to temporary hold data coming from database or class library. This object is used temporarily to catch data and than to return, pass to some function or binding a control.1st: Can this approach harm any way ? I couldn't analyze it but a thought was using such shared variables may replace data in it when multiple users may be sending request at a time?
[code]...
View 2 Replies
May 12, 2010
I have the following page
[Code]....
Currently, only GenericOfflineCommentary's ExtractPageData() is firing. How can I modify this to first run OfflineFactsheetBase's ExtractPageData() and then GenericOfflineCommentary's?
edit: I'm trying to avoid having to call base.ExtractPageData() in every implementor.
View 2 Replies
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
Feb 25, 2010
I have two member roles at my project:
1.) Administrator
2.) Member
From the toolbox in Visual Studio 2008, I have dragged and dropped the create user wizard into the stage. I aim that a guest can register itself and automatically join the "member" role. Not the role "administrator". How can I do that?
View 9 Replies
Jun 24, 2010
I have a WindowsForm that has a DataGridView that shows output of my app. The class with the button is DriveRecursion_Results.cs. I want it so that once the button is pushed by the user, my method FileCleanUp() in my SanitizeFileNames class is called. I'm not quite sure how to do this though.Here is the code for both classes:
public partial class DriveRecursion_Results : Form
public DriveRecursion_Results()
InitializeComponent();
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
[code]...
View 1 Replies