Click here to Skip to main content
15,906,463 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I,m using the following code to call js function


AjaxControlToolkit.ToolkitScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "Display(dt);", true); 


where display is my javsript function name and dt is my date time object.


code in js

Function Display(dt)
{
 alert(dt);
}
Posted
Updated 1-Feb-14 6:16am
v2
Comments
So, what is the issue? What it alerts?

1 solution

Try this

C#
protected void btnDisplay_Click(object sender, EventArgs e)
        {
            DateTime serverDateTime = DateTime.Now;
            // if you are using AJAX Update panel, use this
            //ScriptManager.RegisterStartupScript(this, this.GetType(), "display", "Display('" + serverDateTime + "');", false);

            // if not using AJAX Update panel
            Page.ClientScript.RegisterStartupScript(this.GetType(), "display", "Display('" + serverDateTime + "');");

        }



JavaScript
<script type="text/javascript">

        function Display(dt)
        {
            alert(dt);
        }
    </script>
 
Share this answer
 
Comments
Member 10517120 7-Feb-14 4:42am    
This Worked
Karthik_Mahalingam 7-Feb-14 4:46am    
welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900