Call a js function in C#

I am very new to c#.  I can figure most things out, but can't find documentation on how to do this.  Based on the scenerio below, how do I call a function in the project folder Common/CommonFunctions.js to fill the placeholder Summary2ndHolder with the return string, using a stored procedure to pass part of the parameters needed for the function and hard coding the rest of the parameters?

Scenerio:
.aspx page with a placeholder:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Summary Detail</title>
    <link href="Common/Standard.css" type="text/css" rel="stylesheet">
</head>
<body>
    <form id="form1" runat="server">
         <div id="paContent" class="headersmall">
            <div align="center">
                <asp:Literal ID="SummaryHolder" runat="server" />&nbsp;
                 <asp:Literal ID="Summary2ndHolder" runat="server" />
           </div>
        </div>
   </form>
</body>
</html>

Code behind is C#:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Quality.Business;

namespace Quality.UI
{
    public partial class SummaryDetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
             // get summary detail data
            if (!Page.IsPostBack)
            {
                using (Business.SummaryDetails summaryDetails = new SummaryDetails())
                {
                    SummaryHolder.Text = summaryDetails.GetSummaryDetails(Agent_Code, GroupRatingYear_ID, Server.MapPath("xsl"));
                }
            }
        }
    }
}

CommonFunctions.js
function DoSomething(parm0, parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8)
{
//create the returnstring using passed parameters
     return returnstring;
}
cswebdevAsked:
Who is Participating?
 
surajgupthaCommented:
>>  I just need to know how to call the js function from within my c# codebehind page.

You will not be able to call a java script in the middle of your c# code execution. A javascript is a client side scripting language and will be executed only when the HTML generated by your C# code reaches a browser
0
 
surajgupthaCommented:
You can store the data you might be getting from the stored proc into a javascript hidden variable and then call the js function passing the variable and other variables.

Why cant you set the literal using C# code, why use javascript?
0
 
cswebdevAuthor Commented:
Our mandate is to keep functions in a seperate place and the project already has functions in CommonFunctions.js.  Stored procs are called from individual c# pages and I will have to create one for this stored proc to get the variables, which I can store and use.  I just need to know how to call the js function from within my c# codebehind page.  I hope I explained this correctly.
0
 
cswebdevAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.