Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Calling non-static method from static webmethod

Calling non-static method from static webmethod

Scheduled Pinned Locked Moved ASP.NET
questionsysadminxmltutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DotNetXenon
    wrote on last edited by
    #1

    [System.Web.Services.WebMethod] public static DataSet GetContactName() { DataSet ds = new DataSet(); XmlDocument doc = new XmlDocument(); ds.ReadXml(System.Web.HttpContext.Current.Server.MapPath("App_Data/Group.xml")); LoadData(ds); ????? } I need to bind this ds to a repeater control. public void LoadData(DataSet ds) { DataSet ds = GetContactName(); repeaterGroup.DataSource = ds; repeaterGroup.DataBind(); } My question is, how to call LoadData from above webmethod. LoadData() method is not recognized from the webmethod.

    ------------------------------------------------------------ "The only true wisdom is in knowing you know nothing." --Socrates

    N 1 Reply Last reply
    0
    • D DotNetXenon

      [System.Web.Services.WebMethod] public static DataSet GetContactName() { DataSet ds = new DataSet(); XmlDocument doc = new XmlDocument(); ds.ReadXml(System.Web.HttpContext.Current.Server.MapPath("App_Data/Group.xml")); LoadData(ds); ????? } I need to bind this ds to a repeater control. public void LoadData(DataSet ds) { DataSet ds = GetContactName(); repeaterGroup.DataSource = ds; repeaterGroup.DataBind(); } My question is, how to call LoadData from above webmethod. LoadData() method is not recognized from the webmethod.

      ------------------------------------------------------------ "The only true wisdom is in knowing you know nothing." --Socrates

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      How can a web-service method binds data? If LoadData() method is in your web page and you are trying to call it from web-service, then whatever you are doing is pointless. Do more reading on web-services and how they work before you work on them.

      Navaneeth How to use google | Ask smart questions

      D 1 Reply Last reply
      0
      • N N a v a n e e t h

        How can a web-service method binds data? If LoadData() method is in your web page and you are trying to call it from web-service, then whatever you are doing is pointless. Do more reading on web-services and how they work before you work on them.

        Navaneeth How to use google | Ask smart questions

        D Offline
        D Offline
        DotNetXenon
        wrote on last edited by
        #3

        Everything has a necessity and I wanted to clearly communicate that am not a beginner. Please ask why this is needed if you are interested to help or opt to stay out. There will be somebody else who will be willing to help. When I have posted a question on a forum, it clearly means I am looking for a solution. This is what am trying to achieve. Ajax control, collapsible panel extender(cpe) needs to expand a panel containing a repeater control and load data into repeater when the panel is expanded. I found that there is no server side click event but there is an expand-collapse javascript handler. To call server side code from AJAX, Pagemethods can be used. <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server"> </asp:ScriptManager> [System.Web.Services.WebMethod] public static DataSet GetContactName() { DataSet ds = new DataSet(); XmlDocument doc = new XmlDocument(); ds.ReadXml(System.Web.HttpContext.Current.Server.MapPath("App_Data/Group.xml")); LoadData(ds); } public void LoadData(DataSet ds) { DataSet ds = GetContactName(); repeaterGroup.DataSource = ds; repeaterGroup.DataBind(); } I am not able to access LoadData from GetContactName(). Any help on this would be greatly appreciated.

        ------------------------------------------------------------ "The only true wisdom is in knowing you know nothing." --Socrates

        C 1 Reply Last reply
        0
        • D DotNetXenon

          Everything has a necessity and I wanted to clearly communicate that am not a beginner. Please ask why this is needed if you are interested to help or opt to stay out. There will be somebody else who will be willing to help. When I have posted a question on a forum, it clearly means I am looking for a solution. This is what am trying to achieve. Ajax control, collapsible panel extender(cpe) needs to expand a panel containing a repeater control and load data into repeater when the panel is expanded. I found that there is no server side click event but there is an expand-collapse javascript handler. To call server side code from AJAX, Pagemethods can be used. <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server"> </asp:ScriptManager> [System.Web.Services.WebMethod] public static DataSet GetContactName() { DataSet ds = new DataSet(); XmlDocument doc = new XmlDocument(); ds.ReadXml(System.Web.HttpContext.Current.Server.MapPath("App_Data/Group.xml")); LoadData(ds); } public void LoadData(DataSet ds) { DataSet ds = GetContactName(); repeaterGroup.DataSource = ds; repeaterGroup.DataBind(); } I am not able to access LoadData from GetContactName(). Any help on this would be greatly appreciated.

          ------------------------------------------------------------ "The only true wisdom is in knowing you know nothing." --Socrates

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          you're not a beginner, but you want to know how to call a non static method from a static method ? The only way to do this, is to have an instance of the class that contains the non static method. However, as your control is within a page lifecycle, you can't just create a page instance from out of nowhere, it won't create the lifecycle you need, as a page is not being requested. Therefore, it cannot be done, you need instead to create a page lifecycle, and call your method within that lifecycle. Otherwise, there's no chance you're going to see anything appear in your page.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups