.NET Framework Developer Center > .NET Development Forums > JScript for the .NET Framework > Problem Call a Server-side Method From Jscript file
Ask a questionAsk a question
 

AnswerProblem Call a Server-side Method From Jscript file

  • Tuesday, September 15, 2009 2:59 PMmohsendeveloper Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi;

    I called a server-side method from  javascript function in page.

    <

    SelectReportByPageIndex.ReportID=

     

    but while me put this code in jscript file,server-side method was not called.

    How can me call a server-side method from jscript file?

    Thanks,mohsen 

     

     

    "<%=SetReportID()%>"; </script>
    script type="text/javascript">

Answers

  • Wednesday, September 16, 2009 8:15 AMHarry ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi,

    For the
    questions relating to asp.net ,please post to: http://forums.asp.net/.

    Thanks,
    Harry


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Tuesday, October 20, 2009 1:36 AMBeniwal Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I think it will be difficult call server side method directly from javascript.
    Because the server side page is executed first and then the javascript is rendered.
    So the event anyways need to be processed on the server.
    So you have to make a request to server again.
    And still if you want to call the server side method please try using ASP.NET callbacks implementation.

All Replies

  • Wednesday, September 16, 2009 8:15 AMHarry ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi,

    For the
    questions relating to asp.net ,please post to: http://forums.asp.net/.

    Thanks,
    Harry


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Tuesday, October 20, 2009 1:36 AMBeniwal Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I think it will be difficult call server side method directly from javascript.
    Because the server side page is executed first and then the javascript is rendered.
    So the event anyways need to be processed on the server.
    So you have to make a request to server again.
    And still if you want to call the server side method please try using ASP.NET callbacks implementation.

  • Tuesday, October 20, 2009 3:07 PMpkmooj Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Use Javascript Page method to call server side method.
  • Tuesday, October 20, 2009 3:40 PMGanesh Ranganathan - Bangalore, India Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Use _doPostBack to post the data back to do any server side processing

    Else go for AJAX. As far as i know, there is no other way. Then again, folks at the ASP.NET foums would be able to help you better.
    Ganesh Ranganathan
    [Please mark the post as answer if it answers your question]
    blog.ganeshzone.net