asp.net - Call UserControl method from a static method -


I am trying to make an AJAX call in my ASP.NET application. I have an ASPX page and an Essex page.

I declare my user credit in all my Exxioni.spx first

  & lt;% @ Register TagPrefix = "UC" TagName = "UserControlEccezioni" Src = "~ / Eccezioni.ascx "%> .... & lt; Div & gt; & Lt; UC: User ControlAxcession Runat = "Server" id = "UKCZini" /> gt; & Lt; / Div & gt;   

I have this Ajax function:

  $ .ajax ({type: "POST", url: "Eccezioni.aspx / CheckExistingVariable", data Content Type: "Application / Jason; Charset = UTF-8", Data Type: "Jason", Success: Work () {Warning (Response D): '{var: "' + eccSplitt [i] + ' );}, Failure: function () {warning ("to");}}); I have webmath in eccezioni.aspx.cs:  
  [System.Web.Services.WebMethod] Public Stable Boolean Checking Extensible Vehicle (string) Verb) {return ucEccezioni.CheckExistingVariable (var); }   

The problem is that I can not use my ucEccezioni variable. What can i do

You can not access example methods with a static method. This is an iron-wearing rule, and it means that you can not access the non-static properties or methods of a control (or page) from WebMethod , even if it is WebMethod embedded in the same control or page.

You have several options here:

  1. Instead of using WebMethod in a web page, Code> ucEccezioni.CheckExistingVariable to create a web service>, and calls it through Ajax, which most people recommend.

  2. Make a method ucEccezioni.CheckExistingVariable if you can do this - if checkexchangeable any example property or Does not use methods - it will be a very easy way from your dilemma though, it is less elegant than option 1.

  3. Use a UpdatePanel , if it is compatible with your overall design

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -