locked
WebCustomControl with js file calls from client side to c# RRS feed

  • Question

  • User-533402033 posted

    Hi all,

    I'm developing a complex WebCustomControl based on a Panel.

    This WebCustomControl builds dynamically both html and ajax constituent controls. All JavaScript code is in a file calls UICommon.js.

    The issue is how can I call a C# function (which retrieves database information) within a JavaScript file. I wouldn't like raise events nor use postbacks. I have tried using Webmethods: they are working right on aspx. page but not on a WebCustomControl

    Thank you a lot!!!!!

    Thursday, July 9, 2009 7:29 AM

Answers

  • User2136026738 posted

    Hi,

       PLease correct me if i am wrong If your problem is calling the method please place the method in a basePage and inherite all pages from this BasePage. this way all the pages will have this method and you can call it .

     

    Thanks,

    Ashish.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 10, 2009 3:42 AM

All replies

  • User2136026738 posted

    Hi,

    If your website is AJAX Enabled you can Use Json webervice call.You can call a c# method from JS using this method.


    http://www.codeproject.com/KB/webservices/XML_and_JSON_on_same_We_S.aspx

    Thursday, July 9, 2009 9:04 AM
  • User-533402033 posted

    Hi Ashish,

    thanks for for comment, but I think it's too complex if I need to call a C# funtion. This function only is querying agains DB. Nothing else. Must be a more easy call method for calling C# methods within a .js file function when all the code is in a WebCustomControl...

    I checked Webmethod solutions. Despite to Scriptmanager had  EnablePageMethods="True", PageMethods calls in js file function was undefined. Paradoxically a Webmethod is being called in the page which contains this control, but not inside the control.

    Regards,


    Friday, July 10, 2009 2:26 AM
  • User2136026738 posted

    Hi,

       PLease correct me if i am wrong If your problem is calling the method please place the method in a basePage and inherite all pages from this BasePage. this way all the pages will have this method and you can call it .

     

    Thanks,

    Ashish.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 10, 2009 3:42 AM
  • User-533402033 posted

    Ashish,


    mmm good choice... I will use it...


    Thanks!

    Friday, July 10, 2009 4:33 AM
  • User2136026738 posted

    Hi,

    No problem. Please mark Answer right if it works.

     

    Friday, July 10, 2009 5:13 AM