AJAX :: Calling Non-static Methods From A Static Method?

Jun 30, 2010

I did some research after posting. All I found was simple examples for no-layer architectures, like connecting to a database from your aspx page, so, in a corporate environment, it is unnaceptable.

I need to call a server-side method (using ASP.NET Ajax) in a 3-layer architecture.

For example, my Default.aspx contains a method LoadProducts().

[Code]....

[Code]....

This cannot change. There is no way to convert Business and Data layers to static.

How can I call the LoadProducts() method using ASP.NET Ajax?

View 2 Replies


Similar Messages:

AJAX :: Calling Static Play Method Doesn't Work?

Aug 26, 2010

I have a page with an update contentpanel, with 4 panels inside. Image buttons outside the update panel control control which panel is visible. I am trying to call an animation from a javascript function, but the animation doesn't work, everything else does.

main.aspx:

[Code]....

main.aspx.vb:

[Code]....

web.config:

[Code]....

View 10 Replies

C# - Calling Response.TransmitFile() From Static Method

Feb 16, 2010

I have a number of pages which need to support exporting data to an Excel spreadsheet. I can generate the Excel files just fine, but I'm trying to work out how to abstract this behavior so it's easily reusable from all of the pages where I need it. My current idea is to use a static utility method, as follows:

[Code]....

The click handler where I'm calling SendExcelFile looks like this:

protected void lnkExport_Click(object sender, EventArgs e)
{
List<List<string>> dataList = GatherDataForSpreadsheet();
Utility.SendExcelFile(this, "fileNameForDownload.xlsx", dataList, "MyReports");
}

This code works just fine as an instance method of the calling page. As a static method, though, it doesn't work at all. When I click the button that invokes this, the browser shows the loading animations indefinitely, but never prompts for a file download.

EDIT: If I remove the call to File.Delete() at the end, the method works as expected. Does Response.TransmitFile() do the transfer asynchronously?

EDIT 2: I just needed to call Response.Flush() before I deleted the file.

View 5 Replies

C# - How To Lock A Private Static Field Of A Class In One Static Method

Mar 26, 2011

I have a private static field in my Controller class in an MVC web application.

I have a static method in that controller that assigns some value to that static field, I want to apply lock on that static field until some other instance method in the controller uses the value stored in the static field and then releases it.

DETAILS:

I have a controller named BaseController having a static ClientId field as follows and two methods as follows:-

public static string ClientId = "";
static void OnClientConnected(string clientId, ref Dictionary<string, object> list)
{
list.Add("a", "b");
// I want the ClientId to be locked here, so that it can not be accessed by other requests coming to the server and wait for ClientId to be released:-
BaseController.clientId = clientId;
}
public ActionResult Handler()
{
if (something)
{
// use the static ClientId here
}
// Release the ClientId here, so it can now be used by other web requests coming to the server.
return View();
}

View 1 Replies

Alternative For Static Method In Interface - Enforce Implementing Class-level Methods

Oct 28, 2010

I have a hierarchy in my website project as below:

[CustomControl1 - folder]
- CustomControl1.ascx
- CustomControl1.css
- CustomControl1.js

I load css and js files dynamicaly based on which controls are used on particular page. I am doing it by using following code:

[code]....

where AddLinks method adds HtmlLink controls to Page.Header with href attribute set to coresponding css and/or js file.

I would like to add Interface that would force new controls to have AddLinks method but it is impossible since it is a static method. Because my custom controls inherit from Control class I cannot use abstract class and/or virtual methods either. How can I achieve my goal?

View 1 Replies

Using Extension Methods In Static Methods On Extended Classes?

Aug 16, 2010

I have an extension method as follows:

public static class PageExtensions
{
public static int GetUserId(this Page targetPage)
{
var user = Membership.GetUser(targetPage.User.Identity.Name);
return (int)user.ProviderUserKey;
}
}

Now in a page I need to use this method in a static WebMethod, so I have added another 'extension method' to PageExtensions:

public static int GetUserId()
{
return (int)Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey;
}

and I call it as follows in my WebMethod: PageExtensions.GetUserId()

View 1 Replies

Jquery - Ajax - Call Non - Static Method

Aug 11, 2010

From client side, I need to call a server method that is not static. For example, I got the following user control ucData (private instance of code-behind) that is Databind in the load event. The server method I need should return ucData.IsValid(). So it can't be static

View 1 Replies

C# - How To Call Non-static Page Method With Client AJAX Script

Jan 12, 2010

How can this be done? Does this exclude the UpdatePanel functionality when it's done?

View 1 Replies

C# - Static Methods For Biz Layer?

Nov 18, 2010

Actually I have done all my Biz(business layer) and DAL CRUD Opprations using static methodes
and I just send my error messages to my log table a sample of biz layer

public static bool Delete(Guid LogGroupID)
{
using (DAL.ChroXEntities db = new ChroX.DAL.ChroXEntities())
{
var q = (from lg in db.LogGroupSet

[code]...

so what should i do to propagate an user friendly error to my users?

View 1 Replies

C# - Is It Safe To Access .net Session Variables Through Static Properties Of A Static Object

May 10, 2010

Is it safe to access asp.net session variables through static properties of a static object?Here is what I mean:

public static class SessionHelper
{
public static int Age
{
get
{
[code]...

Is it possible that userA could access userB's session data this way?

View 2 Replies

Web Forms :: How To Access Session In Static Methods

Sep 15, 2010

I write a simple static method in my web page. How can i access session["id"] into method? I dont have access.For example:

public static void myFunc()
{
Session["id"]= 100;
}

View 2 Replies

C# - Making Cache Access Methods Static?

Nov 12, 2010

In ASP.NET, is there any reason not to make a set of functions that Add/Remove/Get from the Cache object Static?Get() - just gets the item, no reason not to be staticAdd(), Remove() - I've read that adding/deleting into the cache has it's own internal locking mechanism, so they can be static without me creating my own lock(){} wrapping.

View 1 Replies

Architecture :: Use STATIC Methods In Data Access Layer?

Feb 4, 2011

I am developing a web application, which has Data Access Layer and this layer has only one class, in which all methods are static methods like static Insert, static Update, static Search. It has no properties. I am using these methods in my Bussiness Logic class for my users who are visiting my website.Now my question is : 1. Is it right to use static methods in this scenario ?2. What will happen if 10 users call Insert method at the same time ?

View 3 Replies

Web Forms :: How To Access The Page Controls In Static Methods

Oct 4, 2010

How to access the page controls in Static methods.

View 2 Replies

C# - Best Way To Integrate Dependency Injection Using Unity When Static Methods Are Used?

Mar 8, 2010

Im faced with an impending upgrade to an ASP.NET site and I am thinking of introducing DI using Unity. I have researched the ASP.NET DI side of things and have 2 options (Global.asax or IHttpModule). Im happy to use either. As always, there is a legacy object model in place that I would like to upgrade/change. I would like to go down the route of Constructor injection (passing in the DAO) however, each object has a mix of static and instance methods that both currently call into the DB using SqlCommand objects themselves. I want this removed to provide DB independence, therefore can anyone suggest the best way to do the DI in this case? Im open to drastic changes if they are needed.

public class ExampleClass
{
public ExampleClass(int test)
{
TestProperty = test;
}
public int TestProperty {get; set;}
public int Save()
{
// Call DB and Save

[Code]....

View 1 Replies

Web Forms :: Difference Between Singleton Design Pattern And Static Methods

May 7, 2015

In one of the interview, I was asked why should we have to go for Single Design pattern, instead of just creating static methods. Because creating static methods also serve the same purpose, i.;e avoiding flooding of objects.

View 1 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

Architecture :: Impact Of Using Static Methods In Business Access Layer In 3 Tier Applciation?

Aug 25, 2010

is there any impact of using static methods in Business Access layer in 3 tier applciation,

View 4 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

How To Assign A Value From A C# Static Method To A Label

Feb 5, 2010

I have the following static function in c#

public static string Greet(string name)
{
string greeting = "welcome ";
// is it possible to pass this value to a label outside this static method?
string concat = string.Concat(greeting, name);
//error
Label1.text = concat;
//I want to return only the name
return name;
}

As you can see in the comments, I want to retain only the name as the return value, however I want to be able to take out the value of the concat variable to asign it to a label, but when i try the compiler refuses, can it be done? Is there a work around?

View 4 Replies

Working With Static Variables / Store The User Specific Information In Static Variables?

Mar 5, 2011

whats the exact use of static variables in overall programming in .net and for asp.net...

Recently i went for the interview where interviewer asked me 2 question which i was not sure for the same..

whats the use of session object, i said sessions are the server side object, they are used when you want to store user specific data at server side, then he asked what if i want to use static variables for the same, i was mum, can anyone tell me how asp.net will behave if i store the user specific information in static variables.If i use cookies which are the best option to store the data at client side (not sensitive one), but what if user has disabled cookies on his machine, will my application would crash.

View 3 Replies

Static Method Can Be Declared Inside Interface?

Apr 4, 2010

Can we declare a static method inside the Interface?If not means Why?

View 4 Replies

Javascript - Access Gridview In Static Method?

Sep 1, 2010

I want to access my gridview in the static method? I am doing async call from javascript, I need code for this,

[System.Web.Services.WebMethod()]
public static void bindGrid(string userinfoId, int row)
{
GridView gv;
gv = (GridView)gvParent.Rows[row - 1].FindControl("gvChild");
gv.DataSource = GetProfileData(userinfoId);
gv.DataBind();
}

i want to access grid view,gridview is not static. I want to know, Is their any possiblity for using gridview in static method.? Yes or No.

View 1 Replies

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?

View 3 Replies

C# - Control Reference Static Method Performance?

Jun 10, 2010

I have just asked which one is better?Static Vs Non-Static? [URL]I would like to take this discussion one step ahead.Consider If i pass reference of Panel control as parameter to Public static method, will static method still rules in performance?

View 1 Replies







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